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 comment
Thank you so much!