01 | local oncd = script.Parent.On.ClickDetector |
02 | local offcd = script.Parent.Off.ClickDetector |
03 | local screen = script.Parent.Screen |
04 | local ison = false |
05 |
06 | if oncd.MouseClick then |
07 | if ison = = false then |
08 | screen.Color = Color 3. new( 190 , 104 , 98 ) |
09 | script.Sound:Play() |
10 | ison = true |
11 | end |
12 | end |
13 | if offcd.MouseClick then |
14 | if ison = = true then |
15 | screen.Color = Color 3. new( 0 , 0 , 0 ) |
16 | script.Sound:Pause() |
17 | ison = false |
18 | end |
19 | end |
The script is doing absolutely nothing, or it is but it's just super fast to the eye. But I can't point out exactly why it is, it looks perfectly good to me. Especially because there aren't errors.
help me.
thanks for reading and or help,
Narwhal
This is probably happening because the script doesn't loop, try using functions, edited code:
01 | local oncd = script.Parent.On.ClickDetector |
02 | local offcd = script.Parent.Off.ClickDetector |
03 | local screen = script.Parent.Screen |
04 | local ison = false |
05 |
06 | oncd.MouseClick:Connect( function () |
07 | if ison = = false then |
08 | screen.Color = Color 3. new( 190 , 104 , 98 ) |
09 | script.Sound:Play() |
10 | ison = true |
11 | end |
12 | end ) |
13 |
14 | offcd.MouseClick:Connect( function () |
15 | if ison = = true then |
16 | screen.Color = Color 3. new( 0 , 0 , 0 ) |
17 | script.Sound:Pause() |
18 | ison = false |
19 | end |
20 | end ) |
Also, if this is a GUI then make sure On and Off are text buttons and use the following code:
01 | local on = script.Parent.On |
02 | local off = script.Parent.Off |
03 | local screen = script.Parent.Screen |
04 | local ison = false |
05 |
06 | on.MouseButton 1 Click:Connect( function () |
07 | if ison = = false then |
08 | screen.Color = Color 3. new( 190 , 104 , 98 ) |
09 | script.Sound:Play() |
10 | ison = true |
11 | end |
12 | end ) |
13 |
14 | off.MouseButton 1 Click:Connect( function () |
15 | if ison = = true then |
16 | screen.Color = Color 3. new( 0 , 0 , 0 ) |
17 | script.Sound:Pause() |
18 | ison = false |
19 | end |
20 | end ) |