Im having some problems to make a level up system, its with GUIs, first I have the script that will change GUI texts to the NumberValue value, it works fine, but I need a script that when the xp is greater than xptolevel its gonna make a action, someone help me!, there's the script: while true do if script.Parent.Value > script.Parent.Parent.xptolevel.Value then print("xp is greater than xptolevel") wait(0.1) end end Here's a screenshot https://imgur.com/a/CgCgN
COMMUNITY QUESTION
ROBLOX - Im having problems with level up system, help me? please! :c
2 answers
works perfectly fine for me. Just make sure you don't have the wait inside the if statement, otherwise game will crash if the statement is not true.
while wait() do
if script.Parent.Value > script.Parent.Parent.xptolevel.Value then
print("xp is greater than xptolevel")
end
end
1 comment
0
Worst way to do this. Why not .Changed?
There is a lot more advanced and less destructive ways to do this.
Assuming you have the GUI interface setup, I will just show you a script. A smarter idea would to also be to put this in StarterGui as a normal server script.
local lighting = game:GetService("Lighting")
for _,x in pairs(lighting:GetChildren())do
x.Changed:connect(function()
if x.Name == "xp" and x.Value >= x.Parent["xptolevel"] then --this may seem sketch but it works fine.
print("Player has leveled up!")
x.Parent["xptolevel"].Value = x.Parent["xptolevel"].Value + 100
if x.Name == "level" then
x.Value = x.Value + 1
end
x.Value = 0
end
end)
end
Hopefully this works fine for you, and yes there are many other ways to do this but why make the variables? YOU CAN PUT THIS SCRIPT ANYWHERE BUT IT MAY BE SAFER TO PUT IN STARTERGUI
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
try if script.Parent.Value = script.Parent.Parent.xptolevel.Value then THIS WILL MAYBE WORK!!! JUST TRY IT!;D
it will not work, and its not one =, its ==. And if the XP passes xptolevel, like 1 punch = 32 xp, and lets say my xp is 91, then when i punch it it will say that its not equal...
https://forum.scriptinghelpers.org/topic/189/please-share-links-correctly https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site