This is the code that isn't working for me.
I just want to move character away from that room that he is in after clicking. I give money when player clicks so i don't want them to keep clicking so any solution would be good. even if player goes back to spawn
function onClicked() local p = game.Players:GetChildren() for i = 1, #p do p[i].Character:MoveTo(Vector3.new(0, 500, 0)) end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Aprishiate all help
The code you have now would teleport every player. To teleport you, the MouseClick
event returns the player who clicked - so you can use the MoveTo
function on the Character
Property of the parameter returned.
connect
is deprecated. Use Connect
!local location = Vector3.new(0,500,0) --Change this to where you want to go to. function onClicked(p) --'p' parameter is who clicked local char = p.Character --get their character and move it char:MoveTo(location) end --'Connect' instead of 'connect' script.Parent.ClickDetector.MouseClick:Connect(onClicked)