Hi,
I am using a VehicleSeat to detect player input which is forwarded to a NumberValue but only if Occupant isn’t equal to nil. The reason why I am using the NumberValue is because there are two vehicleseats, and I only want the system to detect one input
The problem is that the script does not identify when the value changes, with a while true do loop.
I can’t find a solution, here is the script for the vehicleseat detecting the value:
while true do
wait(.01)
if script.Parent.Occupant ~= nil then
script.Parent.Parent.Dir.Value = script.Parent.ThrottleFloat
end
end
This is the script that is supposed to take action on the value changing:
direction = script.Parent.Parent.Parent.Dir.Value
MainPart = script.Parent
hinge = script.Parent.HingeConstraint
while true do
wait(.01)
if direction == 1 then
MainPart.Power.Disabled = false
MainPart.Brake.Disabled = true
hinge.MotorMaxAcceleration = 5
end
if direction == -1 then
MainPart.Power.Disabled = true
MainPart.Brake.Disabled = false
hinge.MotorMaxAcceleration = 8
end
if direction == 0 then
MainPart.Power.Disabled = true
MainPart.Brake.Disabled = true
hinge.MotorMaxAcceleration = 0
end
end
Sorry if the concept is difficult to understand