Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this script loop through a folder in ServerStorage?

Asked by 3 years ago
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent
local plrs = {}
local Place = nil
local dungeon = game.ServerStorage.Dungeons:FindFirstChild(plr.Name)

script.Parent.MouseButton1Click:Connect(function()
    for i, player in pairs(dungeon.Players:GetChildren()) do
        table.insert(plrs,1,game.Players:FindFirstChild(player.Name))
    end
    local placeholder = dungeon.Map.Value .."".. dungeon.Diff.Value .."".. tostring(dungeon.HC.Value)
    Place = game.ReplicatedStorage.IDs:FindFirstChild(tostring(placeholder)).Value
    local RSID = game:GetService("TeleportService"):ReserveServer(Place)
    game:GetService("TeleportService"):TeleportToPrivateServer(Place,RSID,plrs)
end)

This is the script that is supposed to tp you and all players into the correct dungeon, but I always get an error at line 7 saying "Attempt to index nil with Players". I know there is a players folder, correct capitalization and everything, so why isnt this working?

Other notes: -This is a serverscript -It's inside a textbutton -I've had this error before, but I can't fix it the same way as then.

Answer this question