Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
bossay6 62
8 years ago
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

Log in to vote
0
Answered by 8 years ago

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)
0
Why not `hit.Character` instead to replace line 2? BlueTaslem 18071 — 8y
0
either way works i guess. i just like to do it this way RobloxianDestory 262 — 8y
0
Thanks! You really helped, i have learned more things. bossay6 62 — 8y
0
But i have another problem, what if the brick is constantly moving? It wont teleport me to the part. bossay6 62 — 8y
View all comments (2 more)
0
what do you mean by constantly moving? RobloxianDestory 262 — 8y
0
nevermind. bossay123 45 — 7y
Ad

Answer this question