Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My sound won't play?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago
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)


Ad
Log in to vote
0
Answered by
Im_Kritz 334 Moderation Voter
8 years ago

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)

Answer this question