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

Change AngularVelocity of HingeConstraint using scripts?

Asked by 4 years ago

I am making a minigame which there is a spinning red part, and you have to jump over it. If you touch it, you die. That part works.

Currently, I have 2 buttons with ClickDetectors, one for speeding it up and one for slowing it down. I understand the property of the HingeConstraint motor controlling how fast it spins is AngularVelocity. I have tried changing that property with a script when clicked, and the property doesn't change, nor does the speed of the spinner.

Code:

local fasterButton = script.Parent
local cd = fasterButton.ClickDetector
local spinnerVelocity = game.Workspace.spinner.HingeConstraint.AngularVelocity

cd.MouseClick:Connect(function()
    spinnerVelocity += 1
    print("increase speed")
    wait(.2)
end)

Output: increase speed (x11) (but no angularvelocity increase)

How can I make this change the speed of the motor with the buttons?

Thank you!

Answer this question