Your problem might just have been you were creating the sound and playing it under the same if statement, whether it exists or not. If the sound already existed, then the button wouldn't play. I went ahead and fixed that for you. I got this script to work in studio.
local button = game.Workspace:WaitForChild('StatueClick').ClickDetector
if not game.Workspace:FindFirstChild("Ambient") then
Ambient = Instance.new("Sound")
Ambient.Name = "Ambient"
Ambient.Parent = game.workspace
Ambient.SoundId = "rbxassetid://238895410"
Ambient.Volume = 1
end
if not game.Workspace:FindFirstChild('Ambient2') then
ambient2 = Instance.new('Sound', game.Workspace)
ambient2.Name = 'Ambient2'
ambient2.SoundId = 'rbxassetid://180919842'
ambient2.Volume = 1
end
button.MouseClick:connect(function()
ambient2:Play()
end)
1 comment
I got this in the output: 10:55:10.141 - Unable to cast value to std::string