|
| 05 Jul 2012 08:45 PM |
This script is supposed to stop the car from moving when the 'gas' value is 0, and when the 'gas' value is NOT 0, the car can move. Please help me with this script. Thanks. Here is the script:
if script.Parent.Value == 0 then script.Parent.Parent.VehicleSeat.MaxSpeed = 0 elseif script.Parent.Value > 0 then script.Parent.Parent.VehicleSeat.MaxSpeed = 30 end |
|
|
| Report Abuse |
|
|
Hetica
|
  |
| Joined: 02 Apr 2012 |
| Total Posts: 115 |
|
|
| 05 Jul 2012 08:57 PM |
script.Parent.Changed:connect(function(c) if (c=="Value") then local val = script.Parent.Value if (val<1) then script.Parent.Parent["VehicleSeat"].MaxSpeed = 0 else script.Parent.Parent["VehicleSeat"].MaxSpeed = 30 end end end) |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2012 08:58 PM |
Your script is only checking once, and then it proceeds. Make it so it checks every time the vehicle accellerates.
local seat = script.Parent.Parent.VehicleSeat local gas = script.Parent seat.Changed:connect(function(property) if property == "Throttle" and gas.Value <= 0 then seat.MaxSpeed = 0 end end) |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2012 08:59 PM |
| Hetica's will work better. Didn't think of the changed event on the gas value :/ |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2012 09:07 PM |
Hetica's won't work. Idk why, mabye because of the script that changes the gas value. If it is why the script Hetica posted, then someone please change it so it works with Hetica's. Here is the script that changes the gas value:
while wait(20) do if script.Parent.Value > 0 then script.Parent.Value = script.Parent.Value - 1 end end
|
|
|
| Report Abuse |
|
|
|
| 06 Jul 2012 01:01 PM |
I think I know what's wrong with Hetica's. Make sure the script is inside the gas value.
gas = script.Parent
gas.Changed:connect(function() if gas.Value < 1 then script.Parent.Parent["VehicleSeat"].MaxSpeed = 0 end end)
|
|
|
| Report Abuse |
|
|