Hello everyone!
So I made a toggle button that would provide a light, I have 2 sounds that wanted to play when the light was on but it doesn’t.
I have two scripts and a photo of the explorer
https://gyazo.com/639c136e9bcbea6fbb8093a93e3ef734 - photo
First Script (lamp script)
state = false
function onClicked()
wait(0.1)
script.Parent.Sound:Play()
if state == true then
script.Parent.Parent.Light.PointLight.Brightness = 0
state = false
script.Parent.Sound:Stop()
else if state == false then
script.Parent.Parent.Light.PointLight.Brightness = 2
state = true
end
end
end
script.Parent.ClickDetector.MouseClick:connect( onClicked )
---Second Script (Script)
script.Parent.BrickColor = BrickColor.new(2)
function onClick()
if script.Parent.BrickColor == BrickColor.new(2) then
script.Parent.BrickColor = BrickColor.new(1)
script.Parent.Parent.Hid.Transparency = 1
script.Parent.Sound:Play()
script.Parent.Parent.Hid.SurfaceGui.TextLabel.BackgroundTransparency = 1
script.Parent.Parent.Name = "Click to Close"
elseif script.Parent.BrickColor == BrickColor.new(1) then
script.Parent.BrickColor = BrickColor.new(2)
script.Parent.Parent.Hid.SurfaceGui.TextLabel.BackgroundTransparency = 0
script.Parent.Sound:Play()
script.Parent.Parent.Hid.CanCollide = false
script.Parent.Parent.Name = "Click to Open"
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)