I am trying to make a player level up when they have pressed 5 buttons. Both values are stored on a leaderboard. ("Buttons Clicked") and ("Level")

I have a code in my buttons making it so when they are pressed the buttonsclicked value goes up, and it works. But, when the value reaches 5, the player doesn't level up and there is no error in the output

local leaderstats = Instance.new("BoolValue", plr)
leaderstats.Name = "leaderstats"

local buttonsclicked = Instance.new("IntValue", leaderstats)
buttonsclicked.Name = "ButtonsClicked"
buttonsclicked.Value =  0 

local level = Instance.new("StringValue", leaderstats)
level.Name = "Level"
level.Value = 0

while true do
	wait()
	print("waited")
	if plr.leaderstats.ButtonsClicked.Value  >= 5 then
		print("condition met")
		plr.leaderstats.level.Value = 1
		print("leveled up")
		end
end
end)

5 comments

0

which output is printed out?

0

only waited

0

you could try firing remote events/functions

0

If it's a GUI, then you have to use a localscript and use FireClient().

0

can u show me what that would look like in a script?