Sound doesn't play when GUI button clicked

I can’t make the sound camsound play when the GUI button is clicked.

script.Parent.MouseButton1Click:Connect(function()
	local cam = workspace.CurrentCamera
	local player = game.Players.LocalPlayer
	local b2 = workspace.camsys.b2
	local light2b = b2.PointLight
	local static = player.PlayerGui.static
	local Map = script.Parent.Parent.Parent["First Part"]
	
	static.Enabled = true
	cam.CameraSubject = b2
	cam.CameraType = "Attach"
	wait(0.2)
	cam.CameraType = "Fixed"
	light2b.Enabled = true
	
	local camsound = script.Parent.Parent.Parent.Chnage
	local camamb = script.Parent.Parent.Parent.Camamb
	camsound:Play()
	camamb:Play()

end)

Does the sound have a valid id, Correct volume, Is it named “Chnage”?

If so, Is script.parent either a textbutton or imagebutton?

1 Like

Yes, the sound is working and has nothing to do with it.
Here’s a screenshot of the file system:
Five Nights at Freddy's  - Roblox Studio 03.03.2022 15_05_02

Is the button a TextButton and not a TextBox? (They have the same icon)

The button is an invisible text button with nothing written on it.

Can you play it from roblox studio?

If you mean the song then yes. I can play the song in Studio in the properties tab but not with the script

That “Chnage” sound you are trying to play

This script works fine for me.

The sound is used in another script as well that is triggered before the script in question. Maybe that is making it not work?

What does this script do to the sound?

It just plays it. + I think I found the issue. When the first script plays the sound the Property playing is true states on and can’t be triggered anymore so I will not play in the second script.

First off, if you aren’t already, you need to parent the UI to the PlayerGui. Second, if this is a normal script, you need to change LocalPlayer to a different method, because it can’t run in a normal script.

Those are the only reasons it shouldn’t be working,

No, I got it working so no problem. I just added this camsound.Playing = false before the camsound:Play()