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

Why won't this script teleport the player who clicked the part?

function clikk()
game.Player.LocalPlayer.Character.Torso.CFrame = CFrame.new(1, 10, 10)
end
script.Parent.ClickDetector.MouseClick:connect(clikk)

It won't teleport the player who clicked the part or brick. I only WANT to teleport the player who clicked it, NOT all the players in the server

1 answer

✓ Accepted answer

this has to be in a Server Script, not a local script

function clikk(hit)
	local player = game.Workspace:FindFirstChild(hit.Name) -- the player's model who clicked
player.Torso.CFrame = CFrame.new(1, 10, 10)
end
script.Parent.ClickDetector.MouseClick:connect(clikk)

6 comments

0

Why not hit.Character instead to replace line 2?

0

either way works i guess. i just like to do it this way

0

Thanks! You really helped, i have learned more things.

0

But i have another problem, what if the brick is constantly moving? It wont teleport me to the part.

0

what do you mean by constantly moving?

0

nevermind.

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