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

How to Properly Teleport using variables?

Asked by 9 years ago

No output was given. My suggestion is that when it Moves them, it may error.

plr = game.Players.LocalPlayer
z = plr.Up.Value
RandomName = {"SpawnLocation1","SpawnLocation2","SpawnLocation3","SpawnLocation4","SpawnLocation5","SpawnLocation6","SpawnLocation7","SpawnLocation8","SpawnLocation9"}
abcd = {"SpawnLocationU1","SpawnLocationU2","SpawnLocationU3","SpawnLocationU4"}

function Down()
    for i,v in pairs(game.Workspace:GetChildren()) do
    for a,b in pairs(RandomName) do
            if v.Name == b then
    TheRandomizer = RandomName[math.random(#RandomName)]
                plr.Character.Humanoid:MoveTo(game.Workspace[TheRandomizer].Position)
                z = false
            end
        end
    end
end

function Up()
    for i,v in pairs(game.Workspace.Lobby:GetChildren()) do
        for i,v in pairs(game.Workspace:GetChildren()) do
    for a,b in pairs(abcd) do
            if v.Name == b then
    LeRandomizer = abcd[math.random(#abcd)]
                plr.Character.Humanoid:MoveTo(game.Workspace[LeRandomizer].Position)
                z = true
end
end
        end
    end
end

script.Parent.MouseButton1Down:connect(function()
    if z == true then
        Down()
    elseif z == false then
        Up()
    end
end)

Answer this question