hello, i’ve read into statements before and on my previous posts i’ve needed help in the past, but i’m still struggling to get it to work, so when i click the torch i want the lights to come on, but i want them to be able to be turned off as well when you click again, just don’t know how to go about it
tool.Activated:connect(function()
if debounce == true then
debounce = false
togglel = true
actiontrack:Play()
actiontrack:AdjustSpeed(2)
wait(actiontrack.Length)
lightsource.Fire.Enabled = true
lightsource.PointLight.Enabled = true
elseif togglel == true then
lightsource.Fire.Enabled = false
lightsource.PointLight.Enabled = false
end
debounce = true
end)
You could have a variable which checks’ whether the torch is on, I see you implemented it with toggle1, but you also seem to have a debounce are you trying to limit how long before the user can click again ?
local isOn = false
tool.Activated:connect(function()
if isOn == false then
isOn = true
actiontrack:Play()
actiontrack:AdjustSpeed(2)
wait(actiontrack.Length)
lightsource.Fire.Enabled = true
lightsource.PointLight.Enabled = true
else
isOn = false
lightsource.Fire.Enabled = false
lightsource.PointLight.Enabled = false
end
end)
I got it working with some minor edits, there was a debounce but i don’t really care too much if it’s there or not, thanks budddyyyy!!
local isOn = false
tool.Activated:connect(function()
if isOn == false then
isOn = true
actiontrack:Play()
actiontrack:AdjustSpeed(2)
lightsource.Fire.Enabled = true
lightsource.PointLight.Enabled = true
wait(actiontrack.Length)
else
isOn = false
actiontrack:Play()
actiontrack:AdjustSpeed(2)
lightsource.Fire.Enabled = false
lightsource.PointLight.Enabled = false
wait(actiontrack.Length)
end
end)