Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Click On and Off Flashlight script?

Asked by 10 years ago

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)

0
You can shorten it with spotlight.enabled = not spotlight.enabled. GoldenPhysics 474 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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)

Ad

Answer this question