Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)?

6 comments

0

I tried to do that, but it does the same. I'm not sure...

0

I think you're missing an end at the end of your script. Put end) at the last line.

1

I tried to add the end) it's still saying forgot to close do and it wont execute the teleport

0

I edit my post, try to do that.

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.

0

Try adding a second ) after hit.

This discussion is preserved as it was. New answers, comments, and votes are closed.