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, But idk how to add a sound play function when i press the button, 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 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)

1 answer

Log in to vote
0
Answered by 8 years ago

Sounds have a method called Play that you can use to play them. Example usage:

Light.Sound:Play()

0
Thank you so much! 12345gabriel12345 15 — 8y
Ad

Answer this question