Old, simple sound script for menu no longer working

For a small game, there is a menu gui and a sound should be playing while in this menu until you click “Play”. This worked before, but I soon stopped working on the build. Once I picked up the build again, the sound no longer plays in the menu. I am positive that the sound I’m using wasn’t removed by Roblox, so I’m assuming that this is the result of the script, and that its possible that small changes were made to Lua that rendered my script useless. Here is the script below:

local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local Play = script.Parent.Sidebar.Play

repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.CameraPart.CFrame

Play.MouseButton1Click:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom
	script.Parent.Parent:Destroy()
end)

local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://6657098363"
sound.Parent = game:GetService("SoundService")
sound:Play()

Play.MouseButton1Click:Connect(function()
	sound:Pause()
	sound:Destroy()
end)
1 Like

the repeat maybe one of the issues it might not be getting past it to test this just do a print right after it

might also go make sure you have the sound permissions right and set for that place id and might try a loop

you could combine those 2 mousebutton1click functions since they are the same

1 Like

Forgive me, I’m unsure if I understand. Should I just type print under the sound:Play()? And if so, what should I expect to see if somethings wrong?

1 Like

you can put a print or warn right under this part
like

warn(‘TESTING SCRIPT HERE’)

if it goes past the repeat loop then you will see the print if not you won’t see anything

you could also put this at the bottom of the script to know the full script loaded which i do on some of my major scripts sometimes like warn(‘Local Sound Script Loaded’)

1 Like

Try using the player.CharacterAdded:Connect(function(character). CharacterAdded:Wait() doesn’t work for me sometimes for some reason.

1 Like

Thank you, I was able to see the warn under the repeat and I found out in the script output that my place, for some reason, needed to give permission to use the sound I was using. This now works and my menu is back to normal. Thank you for your help!

2 Likes