Помогите с ошибочкооой,пишет типо на строке 14 ошибка(я про строку где local mapFolder = ServerStorage.Maps:FindFirstChild(votedMap))говорит что argument 1 assempt or nil.в общем надеюсь,что найдется илон маск который спасет меня
Скрипт: local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerStorage = game:GetService("ServerStorage")
local events = ReplicatedStorage:WaitForChild("Events")
local mob = require(script.Parent.Mob) local info = workspace.Info
local round = {} local votes = {}
function round.LoadMap() local votedMap = round.ToggleVoting() local mapFolder = ServerStorage.Maps:FindFirstChild(votedMap) if not mapFolder then mapFolder = ServerStorage.Maps.GrassLand end
local newMap = mapFolder:Clone() newMap.Parent = workspace.Map
workspace.SpawnBox.Floor:Destroy()
newMap.Base.Humanoid.HealthChanged:Connect(function(health) if health <= 0 then info.GameRunning.Value = false info.Message.Value = "GAME OVER" end end)
return newMap end
function round.ToggleVoting()
for i= 10, 1 -1 do info.Message.Value = "Map voting (" .. i .. ")" print("Map voting (" .. i .. ")") task.wait(1) end
local maps = ServerStorage.Maps:GetChildren() for i, map in ipairs(maps) do votes[map.Name] = {} end
local winVote = nil local winScore = 0 for name, map in pairs(votes) do if #map > winScore then winScore = #map winVote = name end end
--if not winVote then --local n = math.random(#maps) --winVote = maps[n].Name --end
--return winVote
end
function round.ProcessVote(player, vote)
for name, mapVotes in pairs(votes) do local oldVote = table.find(mapVotes, player.UserId) if oldVote then table.remove(mapVotes, oldVote) print("Old vote removed: ", oldVote) break end end
print("Proccessed vote for ", vote) table.insert(votes[vote], player.UserId) end events:WaitForChild("VoteForMap").OnServerEvent:Connect(round.ProcessVote)
Скрипт:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local events = ReplicatedStorage:WaitForChild("Events")
local mob = require(script.Parent.Mob)
local info = workspace.Info
local round = {}
local votes = {}
function round.LoadMap()
local votedMap = round.ToggleVoting()
local mapFolder = ServerStorage.Maps:FindFirstChild(votedMap)
if not mapFolder then
mapFolder = ServerStorage.Maps.GrassLand
end
local newMap = mapFolder:Clone()
newMap.Parent = workspace.Map
workspace.SpawnBox.Floor:Destroy()
newMap.Base.Humanoid.HealthChanged:Connect(function(health)
if health <= 0 then
info.GameRunning.Value = false
info.Message.Value = "GAME OVER"
end
end)
return newMap
end
function round.ToggleVoting()
for i= 10, 1 -1 do
info.Message.Value = "Map voting (" .. i .. ")"
print("Map voting (" .. i .. ")")
task.wait(1)
end
local maps = ServerStorage.Maps:GetChildren()
for i, map in ipairs(maps) do
votes[map.Name] = {}
end
local winVote = nil
local winScore = 0
for name, map in pairs(votes) do
if #map > winScore then
winScore = #map
winVote = name
end
end
--if not winVote then
--local n = math.random(#maps)
--winVote = maps[n].Name
--end
--return winVote
end
function round.ProcessVote(player, vote)
for name, mapVotes in pairs(votes) do
local oldVote = table.find(mapVotes, player.UserId)
if oldVote then
table.remove(mapVotes, oldVote)
print("Old vote removed: ", oldVote)
break
end
end
print("Proccessed vote for ", vote)
table.insert(votes[vote], player.UserId)
end
events:WaitForChild("VoteForMap").OnServerEvent:Connect(round.ProcessVote)