Insert a ClickDetector
into the part that you are using as a chair. Then use a function to register the click of the player. You then need to call that function with the MouseClick
event.
1 | local clickDetector = Instance.new( "ClickDetector" , part) |
3 | local function onMouseClick(player) |
7 | clickDetector.MouseClick:connect(onMouseClick) |
To slowly change the rotation of an object, I prefer to use a HingeConstraint
. (Note, of course, that the PGS Physics Solver must be enabled.) Attach one attachment to the chair, another to the floor, and put a HingeConstraint
to connect them. Turn the ActuatorType
of the HingeConstraint
to Servo
and mess with the settings until you get what you want. Then turn the Enabled property to off. Then put code into the function to turn on the HingeConstraint
.
1 | local clickDetector = part.ClickDetector |
2 | local hinge = part.HingeConstraint |
4 | local function onMouseClick(player) |
8 | clickDetector.MouseClick:connect(onMouseClick) |