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

How do I change the position of a part?

Asked by
Zeluxis 100
8 years ago

I'm unsure on how to fix this code and why it wont work. Can someone hint me in the right direction?

1function Click()
2    script.Parent.Position=Vector3.FromAxis(17.142,26.116,-263.459)
3end
4 
5game.Workspace.restraint1.ClickDetector.mouseClick:connect(Click)

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Simple change:

1local clicker = script.Parent
2local part = script.Parent.Parent
3 
4clicker.mouseClick:connect(function()
5    part.Position = Vector3.new(0,0,0) --change to position you want
6end)

make sure this is a script inside click detector and make sure the click detector is in a part.

so the order will be part's children is click detector, click detector children is script

Please accept answer and upvote if helped!

Ad

Answer this question