Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 28 Oct 2016 09:57 AM |
My script:
function onClicked(playerWhoClicked) if script.Parent.Active.Value == false and script.Parent.Cooldown.Value == false then script.Parent.Click:Play() script.Parent.Start:Play() wait(script.Parent.Start.TimeLength) script.Parent.Idle:Play() script.Parent.SurfaceGui.TextLabel.Text = "O" script.Parent.SurfaceGui.TextLabel.TextColor3 = Color3.fromRGB(0, 255, 0) script.Parent.Parent.VehicleSeat.Disabled = false script.Parent.Active.Value = true script.Parent.Cooldown.Value = true wait(4) script.Parent.Cooldown.Value = false elseif script.Parent.Active.Value == true and script.Parent.Cooldown.Value == false then script.Parent.Click:Play() script.Parent.Idle:Stop() script.Parent.Stop:Play() wait(script.Parent.Idle.TimeLength) script.Parent.SurfaceGui.TextLabel.Text = "X" script.Parent.SurfaceGui.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0) script.Parent.Parent.VehicleSeat.Disabled = true script.Parent.Active.Value = false script.Parent.Cooldown.Value = true wait(4) script.Parent.Cooldown.Value = false end end script.Parent.ClickDetector.MouseClick:Connect(onClicked)
Problem: The seat stays disabled after I activate the "Ignition".
What is wrong with my script? |
|
|
| Report Abuse |
|
|
|
| 28 Oct 2016 10:15 AM |
Not sure what your issue is without seeing your setup, but here is some cleaner code for easier debugging.
local sp = script.Parent local debounce = false local isActive = false sp.ClickDetector.MouseClick:connect(function() sp.Click:Play() if debounce then return end debounce = true isActive = not isActive if isActive then sp.Start:Play() repeat wait() until not sp.Start.IsPlaying sp.Idle:Play() sp.SurfaceGui.TextLabel.Text = "O" sp.SurfaceGui.TextLabel.TextColor3 = Color3.new(0, 1, 0) sp.Parent.VehicleSeat.Disabled = false else sp.Idle:Stop() sp.Stop:Play() repeat wait() until not sp.Stop.IsPlaying sp.SurfaceGui.TextLabel.Text = "X" sp.SurfaceGui.TextLabel.TextColor3 = Color3.new(1, 0, 0) sp.Parent.VehicleSeat.Disabled = true end wait(4) debounce = false end) |
|
|
| Report Abuse |
|
|
Meowth552
|
  |
| Joined: 17 Dec 2009 |
| Total Posts: 2181 |
|
|
| 28 Oct 2016 11:31 AM |
Workspace VehicleSeat Script Ignition Click (Sound) Idle (Sound) Start (Sound) Stop (Sound) Throttle (Sound) Active (BoolValue set to False) ClickDetector Cooldown (BoolValue set to False) Script (The script in the OP.) SurfaceGui TextLabel |
|
|
| Report Abuse |
|
|