So I'm trying to make it so that if a player touches a part, a button pops up When they press that button, it teleports that player. If you can, please post me a working script. If you just want to bug-fix mine, feel free:
01 | local teleportbutton 1 = script.Teleport 1 -- don't know why I made this |
02 |
03 | script.Teleport 1. TextButton.MouseButton 1 Click:connect( function (m) -- teleport the player when button pressed |
04 | p = m.Parent:findFirstChild( "Humanoid" ) |
05 | if p ~ = nil then |
06 | p.Torso.CFrame = CFrame.new( 0 , 8 , 9 ) |
07 | end |
08 | end ) |
09 | game.Workspace.Teleport 1. Touched:Connect( function () -- show the button |
10 | teleportbutton 1. Enabled = true |
11 | end ) |
12 | game.Workspace.Teleport 1. TouchEnded:Connect( function () -- hide the button |
13 | teleportbutton 1. Enabled = false |
14 | end ) |
All of the parts & things are in the right place, and it's in a LocalScript
Try this. You tried to reference the Torso inside of the Humanoid, but the Torso is located inside of the character.
01 | local teleportbutton 1 = script.Teleport 1 -- don't know why I made this |
02 |
03 | script.Teleport 1. TextButton.MouseButton 1 Click:connect( function (PlayerWhoClicked) -- teleport the player when button pressed |
04 | local Character = PlayerWhoClicked.Character |
05 | local P = Character:FindFirstChildWhichIsA( "Humanoid" ) |
06 | if P ~ = nil then |
07 | Character:FindFirstChild( "Torso" ).CFrame = CFrame.new( 0 , 8 , 9 ) |
08 | end |
09 | end ) |
10 |
11 | game.Workspace.Teleport 1. Touched:Connect( function () -- show the button |
12 | teleportbutton 1. Enabled = true |
13 | end ) |
14 | game.Workspace.Teleport 1. TouchEnded:Connect( function () -- hide the button |
15 | teleportbutton 1. Enabled = false |
16 | end ) |