Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My sound won't play?

i tried this

function onClicked(playerWhoClicked)
    local message = Instance.new('Message', game.Workspace) 
message.Text = "Self Destruction Activated!" 
wait(5)
message:Destroy()
play(game.Workspace.Sound)
end
 
script.Parent.ClickDetector.MouseClick:connect(onClicked)

and sound:Play.game.workspace.sound

2 answers

✓ Accepted answer
function onClicked(playerWhoClicked)
   local message = Instance.new('Message', game.Workspace) 
local Sound = game.Workspace:WaitForChild('Sound')
message.Text = "Self Destruction Activated!" 
wait(5)
message:Destroy()
Sound:Play()  --Use :Play() to play sounds, also try using :WaitForChild() in case the sound hasnt loaded yet.
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)


To play the sound, you got to state the sound first then bind it with the Play function. E.g: Just like you did with message:Destroy()

All I did is fixed line 6:

function onClicked(playerWhoClicked)
    local message = Instance.new('Message', game.Workspace) 
message.Text = "Self Destruction Activated!" 
wait(5)
message:Destroy()
workspace.Sound:Play() --Make sure you spell 'Sound' or 'sound' correctly
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

This discussion is preserved as it was. New answers, comments, and votes are closed.