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

Not teleporting me to the wanted place, how can i fix this?

local clickDetector = script.Parent("clickDetector")

local function onMouseClick(player)
	workspace.Torso.Position = Vector3(92.231,-0.4,5.43)
end

I'm kinda new to script so I don't if i did this right cause it doesnt work.. What i wanted it to do is when i clicked on a part it would teleport me to the x,y,x cordinates HElp!

2 comments

0

What is it doing?

0

There are a ton of problems here...

2 answers

Well, the method you're using is very bad. Use CFrame and see if it works.

local clickDetector = script.Parent("clickDetector")

local function onMouseClick(player)
  player.Character.Torso.CFrame = CFrame.new(92.231,-0.4,5.43)
end

The simple reason you failed it:

--Line 4: You forgot the silliest thing ever:
-- what it should be:

player.Character.Torso.Position = Vector3.new(92.231,-0.4,5.43)

-- what you did

workspace.Torso.Position = Vector3(92.231,-0.4,5.43)

4 comments

0

I don't think workspace.Torso exists as well. It should be player.Character.Torso.Position

0

Okay okay, i Fixed it, please remove downvote.. I can't even chat now, wow..

0

Thanks, I know now that I did the silliest mistake and thanks for helping me fix the problem :D

0

Np, could you please choose the correct answer now? so I can get some rep back? c;

The best way to fix this is here:

Basically what you did wrong is you attempted to move the part "Torso" in workspace, which I believe you were trying to move the player, not a part named "Torso" in workspace. Also, you attempted to move the Position of the torso which would kill the player, hence why I put "HumanoidRootPart" and the CFrame of it.

local clickDetector = script.Parent.ClickDetector

function onMouseClick(player) --please tell me if this is a local script or server script
   player.Character.HumanoidRootPart.CFrame = CFrame.new(92.231,-0.4,5.43) --teleports the player
end

clickDetector.MouseClick:connect(onMouseClick) --connects the function to the mouse click.

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