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

How do I make the position of a block move onClick?

Asked by 10 years ago

This is my script:

function onClicked()
Door = script.parent.parent.Door
    script.Parent.onClicked:connect(Vector3.new(35.1, 4.7, -1.3)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

It's my first script, so I have no idea how to do this. The numbers in Vector3.new(35.1, 4.7, -1.3) are the coordinates of the position I want the part to move to when it is clicked. Could anybody fix this script so it works? I haven't tried anything else because I have no idea what I could do.

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Well, there was some capitalization mistakes, and your connection made no sense.

door = script.Parent.Parent.Door
cd = script.Parent.ClickDetector -- have this lead to the click detector

cd.MouseClick:connect(function()
    door.Position = Vector3.new(35.1, 4.7, -1.3)
end)

If you want it to slide, that's another story.. Use a loop.

Ad

Answer this question