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

Why is this script that's supposed to teleport players not working?

Asked by 8 years ago

The script is supposed to teleport players based on their teams after they spawn when a certain value becomes true.

However, the script is not doing anything, and Output has given me nothing. I have no idea what the problem is. Can someone please help me?

Here's the script:

local Playing = game.ServerScriptService.MainGameScript.Variables:WaitForChild("Playing")
local Player = game.Players.LocalPlayer
local TeleVal = Player:WaitForChild("Teleported")
local Map = game.ServerScriptService.MainGameScript.Variables:WaitForChild("Map")

while wait(0.1) do
    if Playing.Value == true and TeleVal.Value == false and Map.Value ~= " " then
        local Thingy = game.Workspace:WaitForChild("Map")
        BB = {} 
        DD = {}
        GG = {}
        RR = {}
        local Spawns = Map:WaitForChild("Spawns")
        local BBS = Spawns:WaitForChild("BBS")
        local DDS = Spawns:WaitForChild("DDS")
        local GGS = Spawns:WaitForChild("GGS")
        local RRS = Spawns:WaitForChild("RRS")
        for i,v in ipairs(BBS:GetChildren()) do
            if v.Name == "Spawn" then
                table.insert(BB,v)
            end
        end
        for i,v in ipairs(DDS:GetChildren()) do
            if v.Name == "Spawn" then
                table.insert(DD,v)
            end
        end
        for i,v in ipairs(GGS:GetChildren()) do
            if v.Name == "Spawn" then
                table.insert(GG,v)
            end
        end
        for i,v in ipairs(RRS:GetChildren()) do
            if v.Name == "Spawn" then
                table.insert(RR,v)
            end
        end
        TeleVal.Value = true
        if Player.TeamColor == BrickColor.new("Bright red") then
            Player.Character.Humanoid:MoveTo(RR[math.random(1,#RR)].Position)
        elseif Player.TeamColor == BrickColor.new("Bright blue") then
            Player.Character.Humanoid:MoveTo(BB[math.random(1,#BB)].Position)   
        elseif Player.TeamColor == BrickColor.new("Bright yellow") then
            Player.Character.Humanoid:MoveTo(DD[math.random(1,#DD)].Position)
        elseif Player.TeamColor == BrickColor.new("Bright green") then
            Player.Character.Humanoid:MoveTo(GG[math.random(1,#GG)].Position)   
        end
    end
end
1
Local scripts cant access server script service. User#11440 120 — 8y
0
I changed it, and it still doesn't work CoolJohnnyboy 121 — 8y
0
Can you print something under line 7 to see if it actually executes? XAXA 1569 — 8y
0
It does not execute, I've tried that. I've decided to use spawns for the game instead CoolJohnnyboy 121 — 8y

Answer this question