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

Game plays music if player is greater than stage one?

Asked by 8 years ago

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.

0
Is the stage value Loaded before you try to play it? Try adding a player:WaitForDataReady() then try it. deputychicken 226 — 8y
0
In line 2 why are searching to see if a leaderstat's stage is less than 1 when you mentioned you are searching the leaderstat's stage to see if its greater than 1?!? UserOnly20Characters 890 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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)

Ad

Answer this question