Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Click On and Off Flashlight script?

I been trying to work on a flashlight, That's turn on or off when you click.

This is the script I worked on. I am not good at scripting but I have random ideas that may end up working.

Here is the script

function click()
if script.Parent.H5.SpotLight.Enabled == false then
script.Parent.H5.SpotLight.Enabled = false
script.Parent.Click:play()
elseif script.Parent.H5.SpotLight.Enabled == false then
script.Parent.H5.SpotLight.Enabled = true
script.Parent.Click:play()
end
end

script.Parent.Activated:connect(click)

1 comment

0

You can shorten it with spotlight.enabled = not spotlight.enabled.

1 answer

✓ Accepted answer

try

function click() if script.Parent.H5.SpotLight.Enabled == false then script.Parent.H5.SpotLight.Enabled = false script.Parent.Click:play() else script.Parent.H5.SpotLight.Enabled = true script.Parent.Click:play() end end

script.Parent.Activated:connect(click)

This discussion is preserved as it was. New answers, comments, and votes are closed.