I'm trying to make it so if the leaderstats of the character is greater than 1 then a welcome back audio plays. The location of everything in the script is correct. I do not know why it will not play.
function onPlayerEntered(player) if player.leaderstats.Stage.Value < 1 then game.Workspace.Sounds.Welcomeback:play() wait(8) game.Workspace.Sounds.Welcomeback.Volume = .4 wait(.5) game.Workspace.Sounds.Welcomeback.Volume = .3 wait(.5) game.Workspace.Sounds.Welcomeback.Volume = .2 wait(.5) game.Workspace.Sounds.Welcomeback.Volume = .1 wait(.5) game.Workspace.Sounds.Welcomeback:pause() end game.Players.PlayerAdded:connect(onPlayerEntered)
Thank you for the help.
You forgot a end
, and you were checking if the value was less then 1
which would be 0
, or -1, -2
etc.
function onPlayerEntered(player) if player.leaderstats.Stage.Value > 1 then -- Replaced < with >, it'll check if the value is greater game.Workspace.Sounds.Welcomeback:Play() wait(8) game.Workspace.Sounds.Welcomeback.Volume = .4 wait(.5) game.Workspace.Sounds.Welcomeback.Volume = .3 wait(.5) game.Workspace.Sounds.Welcomeback.Volume = .2 wait(.5) game.Workspace.Sounds.Welcomeback.Volume = .1 wait(.5) game.Workspace.Sounds.Welcomeback:Pause() -- Or stop end end game.Players.PlayerAdded:connect(onPlayerEntered)