Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local seat = script.Parent
- local mS = seat.MaxSpeed
- local gas = seat:WaitForChild("Gas")
- local gui = seat:WaitForChild("GGui")
- local gClone = gui:Clone()
- local on = false
- local usable = true
- local consume = false
- local consumeWhenIdel = true -- wherther or not to count idel time as using gas
- local refuelable = true -- whether or not it can be refueled
- local infiniteGas = false -- whether or not gas is needed
- local rateOfConsume = 1 -- Persecond of use and use when idel
- local extraToMove,extraRate,turning,tRate = true,2,true,.5 -- the first value is whether
- -- or not it cost extra gas to move (true or false) the second value is how much extra
- -- per second of use, turing is whether or not turing counts, and the last is the rate
- -- of turing (false means the same amount as extraRate)
- local list = script.Parent.Parent
- local player
- if not infiniteGas then
- local check = coroutine.create(function()
- while true do
- if gas.Value > 0 then
- seat.MaxSpeed = mS
- elseif gas.Value<=0 then
- seat.MaxSpeed = 0
- end
- gas.Changed:wait()
- end
- end)
- coroutine.resume(check)
- local consumeIdelGas = coroutine.create(function()
- while usable or refuelable do
- while on do
- if consume or consumeWhenIdel then
- if extraToMove then
- if consume == "steer" then
- gas.Value=gas.Value-((rateOfConsume*.1)+(tRate*.1))
- elseif consume == "ST" then
- gas.Value=gas.Value-((rateOfConsume*.1)+(tRate*.1)+(extraRate*.1))
- else
- gas.Value=gas.Value-((rateOfConsume*.1)+(extraRate*.1))
- end
- else
- gas.Value=gas.Value-(rateOfConsume*.1)
- end
- end
- wait(.1)
- end
- if gas.Value < 0 then gas.Value = 0 end
- wait()
- end
- end)
- coroutine.resume(consumeIdelGas)
- local checkGas = coroutine.create(function()
- while true do
- usable = not seat.Disabled
- if not usable then
- if not refuelable then
- break
- else
- usable = not seat.Disabled
- end
- end
- seat.Changed:wait()
- end
- end)
- coroutine.resume(checkGas)
- if extraToMove then
- local engine = coroutine.create(function()
- local moving,throttle,steer = false
- while true do
- while on do
- local move = seat.Changed:wait()
- if move == "Throttle" then
- throttle = not throttle
- end
- if move == "Steer" then
- if turning then
- steer = not steer
- end
- end
- if steer or throttle then
- moving = true
- else
- moving = false
- end
- if turning and tRate then
- if steer and not throttle then
- consume = "steer"
- elseif steer and throttle then
- consume = "ST"
- else
- consume = moving
- end
- else
- consume = moving
- end
- end
- if not usable and not refuelable then
- break
- end
- wait()
- end
- end)
- coroutine.resume(engine)
- end
- function stop(weld)
- if weld.ClassName == "Weld" then
- gClone.Parent = nil
- on = false
- player = false
- end
- end
- function start(weld)
- if weld.ClassName == "Weld" then
- player=game.Players:GetPlayerFromCharacter(weld.Part1.Parent)
- gClone.Parent = player:WaitForChild("PlayerGui")
- on = true
- end
- end
- seat.ChildAdded:connect(start)
- seat.ChildRemoved:connect(stop)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement