-- [Level Problem Solved]
In this code you are only executing :GetChildren() once and then using that old data.
This doesn’t allow the player to update and probably make the for loop not run at all.
so try this:
-local players = game.Players:GetChildren()
while true do
print("waiting")
wait(.5)
+local players = game.Players:GetChildren() --Now it is getting a list of updated players every loop
for i,v in pairs(players) do -- nothing after here does anything at all but, it continues to loop.
Nope, still doesn’t work
The issue still seems to be there
it wont work past the line that says
if v.leaderstats.XP.Value >= v.leaderstats.XpNeeded.Value then
I also fixed that a second ago and its still having the issue
-- [Level Problem Solved]
Line 34 and 35 don’t work for some reason
You probably should remove the pcall it doesn’t work because it’s an error.
This is why errors are important and why you shouldn’t use pcall in this scenario for changing properties.
while true do
local players = game.Players:GetChildren()
print("waiting")
wait(.5)
for i,v in pairs(players) do -- nothing after here does anything at all but, it continues to loop.
print(v.leaderstats:FindFirstChild("XP").Value)
print(v.leaderstats:FindFirstChild("XpRequired").Value)
v.leaderstats:FindFirstChild("XP").Value += 250
if v.leaderstats:FindFirstChild("XP").Value >= v.leaderstats:FindFirstChild("XpRequired").Value then
print("changed")
v.leaderstats:FindFirstChild("Level").Value = v.leaderstats:FindFirstChild("Level").Value + 1
v.leaderstats:FindFirstChild("XP").Value = 0
v.leaderstats:FindFirstChild("XP").Value = v.leaderstats:FindFirstChild("XP").Value * 1.26
end
end
end
and it’ll work
Thank you, I modified the script to work do that it would adjust the XpRequired and so that it would successfully subtract the Xp value with the xp required. I can finally implement this into my larger scripts.