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

Button pressing into sound?

Asked by 10 years ago

Hello guys, I just wanted to know when I press this button "Script Below" I want it to play music, please can someone tell me!

BoolValue = script.Parent.Parent.EmergencyLight1.Toggle

function onClick()
    if BoolValue.Value == false then
        BoolValue.Value = true
        print(BoolValue.Value)
    else BoolValue.Value = false
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

Best regards, Nathan.

PS: Used random tag since no tag available for the question I am asking.

1 answer

Log in to vote
0
Answered by 10 years ago

Ok. So what you need to do is put a sound in workspace or the part (You need to change it depending on where)

BoolValue = script.Parent.Parent.EmergencyLight1.Toggle
sound=game.Workspace.Sound -- Change this to wherever the sound is, and the sounds name
--Im not sure when you want it to play, So I will put it next to the print, and you can move it.

function onClick()
    if BoolValue.Value == false then
        BoolValue.Value = true
        print(BoolValue.Value)
    sound:Play()
    else BoolValue.Value = false
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClick)

0
Thank you! :D It worked perfectly for my Nuclear Meltdown... HEHEH >:3 WelpNathan 307 — 10y
Ad

Answer this question