I’m trying to recreate the cart ride system. To make the cart move forward or backward, each individual wheel spins by using AngularVelocity, a number value, from a HingeConstraint Motor.
Since I have multiple AngularVelocity values to update, how do I update all of them at once without having to write code for each individual HingeConstraint? Any amount of help will do.
local wheels = game.Workspace.CART.Wheels -- put your path to the wheels folder here
for i,v in pairs(wheels:GetChildren()) do -- v is whatever it finds as a child of wheels, so it finds the parts the hinge constraints are under
if v:FindFirstChild("HingeConstraint") then
v:FindFirstChild("HingeConstraint").AngularVelocity = -6 -- or, whatever number you may want it to be
end
end
Even if my example doesn’t fit your use case/solve your issue, I very much do recommend looking at for loops in general, because I’m certain they’re the solution to your problem. I wish you the best of luck!