generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: What is wrong with my "Ignition" script?

Previous Thread :: Next Thread 
Meowth552 is not online. 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
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image