|
| 18 Nov 2014 11:12 PM |
I want to make a script where when a player touches a certain brick, that brick will teleport them.
How would I do this? |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2014 11:22 PM |
teleportTo = Vector3.new(x,y,z) -- Put the location you want to local buttonPressed = false --Store whether the button is pressed in a local variable script.Parent.Touched:connect(function(hit) if not buttonPressed then -- Is it not pressed? buttonPressed = true -- Mark it as pressed, so that other handlers don't execute print("Button pressed") wait(1) pcall(function() hit.Parent.Torso.Position = teleportTo end) -- Do Stuff buttonPressed = false -- Mark it as not pressed, so other handlers can execute again end end) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 18 Nov 2014 11:37 PM |
@ninja
nevermind about local variables, but it kills me when I teleport? |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2014 11:39 PM |
| Does only your torso go to where you teleport? Because that would be hilarious. Output? |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2014 11:41 PM |
yep it's only the torso
and in output it just says "Button pressed" |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2014 11:48 PM |
teleportTo = Vector3.new(x,y,z) -- Put the location you want to local buttonPressed = false --Store whether the button is pressed in a local variable
script.Parent.Touched:connect(function(hit) if not buttonPressed then -- Is it not pressed? buttonPressed = true -- Mark it as pressed, so that other handlers don't execute
print("Button pressed") wait(1) pcall(function() hit.Parent:MoveTo(teleportTo) end) -- Do Stuff buttonPressed = false -- Mark it as not pressed, so other handlers can execute again end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Nov 2014 11:55 PM |
| what the other guy was doing wrong was, setting position, which will only move said block, not everything attached to it. You could use .CFrame or :MoveTo() on the model. |
|
|
| Report Abuse |
|
|
| |
|