Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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
0
could you provide the full error? Benbebop 1049 — 3y
0
attempt to call a nil value WatsPlayzROBLOX 80 — 3y
0
Does you setting "Close functions" or something along that line disabled? PoWerofThEePg 43 — 3y
0
PoWerofThEePg, dont quite understand what you meant? WatsPlayzROBLOX 80 — 3y
View all comments (3 more)
0
int.Changed:Connect() <--- This is wrong. Roger111 347 — 3y
0
Look at the example here and see how yours is very different: https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed Roger111 347 — 3y
0
And by the way I'm just 8 so please do not judge me too too hard... PoWerofThEePg 43 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

Ad

Answer this question