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

Why is my script not teleporting my players?

Asked by 10 years ago

So I am trying to get this script to teleport players at a certain time to bricks called "Spawns" in my game. The problem is that the teleport part of the script isn't working.....

In the output it says the problem is that...."'Spawns' (a nil value)" even though they are in the game.

`       spawns = gameChosenClone.Spawns:GetChildren()
    for i,v in pairs(game.Players:GetPlayers()) do
        name = v.Name
        check = game.Workspace:FindFirstChild(name)
        if check then
            checkHumanoid = check:FindFirstChild("Humanoid")
            if checkHumanoid then 
                check:MoveTo(spawns[i].Position)
            end
        end
    end
    for i = 3, 1, -1 do`
0
I forgot to mention that the output also mentioned that the problem was on line 8. Bobbysayhi 0 — 10y
0
Please post the full script. Articulating 1335 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

Try using the "PlayerAdded" instance instead of "Spawns" because that isnt specific enough for the scrip to render, if you were to make that work you would have to specify the path and what object you are trying to get to teleport for it to tell if the "spawns" is true, plus, the function is Spawn, not spawns, which in any programming language, the slightest misspellings can lead to tedious hours of work looking for the issue. Also, gameChosenClone.Spawns again, Spawn, not spawns, vitally crucial difference there. As well as the proper variable seperation would be game.ChosenClone. In line 08 is the check:MoveTo(spawns[i].Position) supposed to be the Spawn class as already stated or is it the name of a model? Other than these issues, it looks just fine. Remember, there is more than one way to do things in any language. Stay open-minded and most importantly have fun with it.

0
**I noticed you stated the output says the issue is on line 08. Make sure that the "spawns" is properly mapped to a part that you want the player to be teleported to. If that does not work, you could place a part and get its coordinate values and put those into the script instead. areiydenfan00 115 — 10y
0
I'm not sure if I confused you in this way by naming the bricks that people are teleported to "Spawns" but that is the exact name of the brick people are supposed to be brought to, not an actual respawn area. Shouldn't I leave it exactly the way the model is named? Bobbysayhi 0 — 10y
Ad

Answer this question