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

intValue of Level wont change when xp and maxXp are equal?

Here is my script, and i tried to make it so when the amount of xp and maxXp are equal the xp value will reset, the maxXp value will become higher by 250 and the level will raise by 1, but it just says attempt to call nil value?

local int3 = game.Players.LocalPlayer:WaitForChild("leaderstats")
local int = game.Players.LocalPlayer.leaderstats:WaitForChild("xp")
local int2 = game.Players.LocalPlayer.leaderstats:WaitForChild("maxXp")
local level = game.Players.LocalPlayer.leaderstats:WaitForChild("level")
int.Changed:Connect()
if int.Value == int2.Value then
	level.Value = level.Value + 1
	int.Value = 0
	int2.Value = int2.Value + 250
	end

7 comments

0

could you provide the full error?

0

attempt to call a nil value

0

Does you setting "Close functions" or something along that line disabled?

0

PoWerofThEePg, dont quite understand what you meant?

0

int.Changed:Connect() <--- This is wrong.

0

Look at the example here and see how yours is very different: https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed

0

And by the way I'm just 8 so please do not judge me too too hard...

1 answer

Just figured it out, had to just put xp.Changed and use a function!

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