Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My level system does not work, instead of leveling up it keeps going, what is wrong with script?

like, everything works, when I walk exp goes up as expected but when exp hits max it does not level up, it just keeps going, here is my script in serverscriptservice, I apologize for bad english

local maxXp = 20
game.Players.PlayerAdded:Connect(function(player)
	local levelinfo = Instance.new("Folder")
	levelinfo.Name = "LevelsInfo"
	levelinfo.Parent = player
	
	local level = Instance.new("IntValue")
	level.Name = "Level"
	level.Value = 1
	level.Parent = levelinfo
	
	local exp = Instance.new("IntValue")
	exp.Name = "Experience"
	exp.Value = 0
	exp.Parent = levelinfo
	
	
	local xpNeeded = Instance.new("IntValue")
	xpNeeded.Name = "expNeeded"
	xpNeeded.Value = 20
	xpNeeded.Parent = levelinfo
	
	
	exp.Changed:Connect(function(newExp)
		if exp.Value >= xpNeeded.Value then
			level.Value += 1
			exp.Value -= xpNeeded.Value
			xpNeeded.Value = xpNeeded.Value + 2
		end
	end)
	
end)

this part here does not seem to do anything

	exp.Changed:Connect(function(newExp)
		if exp.Value >= xpNeeded.Value then
			level.Value += 1
			exp.Value -= xpNeeded.Value
			xpNeeded.Value = xpNeeded.Value + 2
		end
	end)

4 comments

0

Are you sure that you are Changing the Values for the exp from the Server.

0

Yes, it shows on gui too and when I test it and check it exp value goes up.

0

does the exp.Changed function fire?

0

idk what happened but I copied everything in that script then deleted whole script, then created new script at same place and copied all stuff in it, now it works

1 answer

I tried recreating the problem, but there seems to be no Problem. I have sent my .rblx file as an example to how it may work

Test_Works.rbxl

This discussion is preserved as it was. New answers, comments, and votes are closed.