NOTE: You only need one Sound object.
First of all, try making a table/metatable(I just call it table) with all the SoundId and amount of currency required:
local Sounds = {
["123456789"] = 10,
["987654321"] = 20,
}
Make a function(@Y0_dude) that get the amount of currency the player has when the amount changes:
leaderstats.Stage.Changed:Connect(function(Amount)
end)
Inside the function would be a For loop that checks the things inside the table, changes the soundId corresponding to the value it is, and plays the Sound:
for i,v in pairs(Sounds) do
if leaderstats.Stage.Value == v then
Sounds.soundId = i
Sounds:Play()
end
end
If you put it all together, it should be like this:
local Sounds = {
["123456789"] = 10,
["987654321"] = 20,
}
leaderstats.Stage.Changed:Connect(function()
for i,v in pairs(Sounds) do
if leaderstats.Stage.Value == v then
Sounds.soundId = i
Sounds:Play()
end
end
end)
3 comments
the colon between connect and function is underlined in red and it wont work
I made a typo. It should be fixed now.
where am i supposed to insert the script? (it didn't work in workspace or startergui)