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

ROBLOX - Im having problems with level up system, help me? please! :c

Asked by 6 years ago

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

0
try if script.Parent.Value = script.Parent.Parent.xptolevel.Value then THIS WILL MAYBE WORK!!! JUST TRY IT!;D Lolamtic 63 — 6y
0
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... feferoblox 12 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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
0
Worst way to do this. Why not .Changed? hiimgoodpack 2009 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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****

Answer this question