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

How i make a sound play when i press this button?

Asked by 8 years ago

I Have this script, i want make a sound play too but do'nt is working, someone can help? Thanks

function ToggleLight()
    if script.Parent.Parent.Parent.LightState.Value == false then
        script.Parent.Parent.Parent.LightState.Value = true
        script.Parent.BrickColor = BrickColor.new("Bright green")
        for i = 1, lights do
            script.Parent.Parent.Parent:FindFirstChild("Lamp" .. i).Light.Material = Enum.Material.Neon
            script.Parent.Parent.Parent:FindFirstChild("Lamp" .. i).Light.SpotLight.Enabled = true
            script.Parent.Parent.Parent:FindFirstChild("Lamp" .. i).Light.Sound.Play() -- sound
            if script.Parent.Parent.Parent:FindFirstChild("Lamp" .. i) == nil then break end
        end
    else
        script.Parent.Parent.Parent.LightState.Value = false
        script.Parent.BrickColor = BrickColor.new("Bright red")
        for i = 1, lights do
            script.Parent.Parent.Parent:FindFirstChild("Lamp" .. i).Light.Material = Enum.Material.Plastic
            script.Parent.Parent.Parent:FindFirstChild("Lamp" .. i).Light.SpotLight.Enabled = false
            if script.Parent.Parent.Parent:FindFirstChild("Lamp" .. i) == nil then break end
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(ToggleLight)
0
At-least attempt to make a sound play... NotSoNorm 777 — 8y
0
I tried but don't is working 12345gabriel12345 15 — 8y
0
I think there's something wrong 12345gabriel12345 15 — 8y

Answer this question