So in the game I'm making, you're able to take over control points. Take over all of them and a value for your team called "Moral" is increased by 10, and the other team's value is decreased by 5. The problem is I only want to play a song if the value changes by a positive value, but I only know how to play the song if it changes in general. Here's my script below:
wait(1.2)
while true do
wait(.1)
local Moral = game.Teams.Prussians.Moral.Value
local Moral2 = game.Teams.French.Moral.Value
script.DieWachtAmRhein:Play()
wait(102)
script.FrenchAnthem:Play()
wait(146.5)
script.PreussensGloria:Play()
wait(168.5)
function ChangedGerman()
if Moral == Moral + 10 then -- my attempt to only play a new song if
--it changes by a positive value.
script.DieWachtAmRhein:Stop()
script.FrenchAnthem:Stop()
script.PreussensGloria:Stop()
game.Workspace.GlobalSoundPlayer.Argonnerwaldlied:Play()
game.Teams.Prussians.Moral.Changed:Connect(ChangedGerman)
end
end
end

1 comment
If you’re listening for a change in value, then just add something thats checks if newvalue >= oldvalue