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

How would you make an OnTouch teleport to brick (part)?

The player walks on to a brick(part) and then gets teleported to another brick (part).

How would this work in Lua?

1 answer

✓ Accepted answer
local part = script.Parent -- put script in part that teleports the player when touched otherwise edit
local teleportTo = game.Workspace.TELEPORTPART -- edit this line. part where player is teleported to

part.Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		player.Character:MoveTo(teleportTo.Position)
	end
end)

9 comments

0

If he wants an explanation then he can ask and I'll happily answer his questions. The code is pretty straight forward so I'm not going to waste my time to sugar coat it (especially after he "accepted" my answer..

0

You should not use debounce in this code snippet. It will have a negative side affect if multiple players step on the brick at once. There is no need for it here. You should remove it from your code. -- I have edited your post to remove the debounce.

0

You're kiding, right?

0

No, I am correct- you should not us debounce in this situation.

0

There was never a debounce.

0

There was, I removed it from your post.

0

You're my hero. You don't get a cookie though.

0

Just because the asker has marked the answer as acceptable, even without an explanation, that doesn't mean that anyone else who views the question will understand what is happening.

0

Then they could ask or find out for themselves. I'm not going to explain how to insert a BasePart and a script into the explorer, that would be redundant.

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