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

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

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

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.

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