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

Why isn't the "function" doing anything (Making the screen terracota, playing the sound, etc. etc.)?

Asked by 4 years ago
local oncd = script.Parent.On.ClickDetector
local offcd = script.Parent.Off.ClickDetector
local screen = script.Parent.Screen
local ison = false

if oncd.MouseClick then
    if ison == false then
        screen.Color = Color3.new(190, 104, 98)
        script.Sound:Play()
        ison = true
    end
end
if offcd.MouseClick then
    if ison == true then
        screen.Color = Color3.new(0, 0, 0)
        script.Sound:Pause()
        ison = false
    end
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

1 answer

Log in to vote
0
Answered by 4 years ago

This is probably happening because the script doesn't loop, try using functions, edited code:

local oncd = script.Parent.On.ClickDetector
local offcd = script.Parent.Off.ClickDetector
local screen = script.Parent.Screen
local ison = false

oncd.MouseClick:Connect(function()
    if ison == false then
        screen.Color = Color3.new(190, 104, 98)
        script.Sound:Play()
        ison = true
    end
end)

offcd.MouseClick:Connect(function()
    if ison == true then
        screen.Color = Color3.new(0, 0, 0)
        script.Sound:Pause()
        ison = false
    end
end)

Also, if this is a GUI then make sure On and Off are text buttons and use the following code:

local on = script.Parent.On
local off = script.Parent.Off
local screen = script.Parent.Screen
local ison = false

on.MouseButton1Click:Connect(function()
    if ison == false then
        screen.Color = Color3.new(190, 104, 98)
        script.Sound:Play()
        ison = true
    end
end)

off.MouseButton1Click:Connect(function()
    if ison == true then
        screen.Color = Color3.new(0, 0, 0)
        script.Sound:Pause()
        ison = false
    end
end)
0
yes did work :0 NarwhalAndMe 141 — 4y
0
Happy to help Lord_WitherAlt 206 — 4y
Ad

Answer this question