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

Having trouble teleporting all players when a tool collides with a block?

Asked by 3 years ago

Once the tool handle hits the block, I want it to wait a few seconds then teleport everyone to the new position. I'm trying to do this but each time I test it, it doesn't work. The script is giving me an error as well that says forgot to close then and do. Here's my script so far.

script.Parent.Touched:connect(function(hit)
    if hit.Name == "Handle" then
        wait(3)
        local p = game.Players:GetChildren()
        for i = 1, #p do p[i].Character:MoveTo(Vector3.new(0, 38.8, 1))
        end

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Try this for teleporting the players instead:

script.Parent.Touched:connect(function(hit)
if hit.Name == "Handle" then
        wait(3)
        for a, b in pairs(game.Players:GetPlayers() do
            b:WaitForChild("Character"):WaitForChild("HumanoidRootPart").CFrame = CFrame.new(Vector3.new(0, 38.8, 1))
        end
    end
end)

Also it looks like you're missing an end at the end of your script, maybe add this after the end in your script: end)?

0
I tried to do that, but it does the same. I'm not sure... NortonHDD 21 — 3y
0
I think you're missing an end at the end of your script. Put end) at the last line. e6_4KOkGsp 40 — 3y
1
I tried to add the end) it's still saying forgot to close do and it wont execute the teleport NortonHDD 21 — 3y
0
I edit my post, try to do that. e6_4KOkGsp 40 — 3y
View all comments (2 more)
0
I believe it has something to do with the function, I tried it alone and it teleported. It's just the first part that needs changing. NortonHDD 21 — 3y
0
Try adding a second ) after hit. e6_4KOkGsp 40 — 3y
Ad

Answer this question