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

Event Firing Repeatedly? Meant to fire each time u reach a new level.

Asked by 3 years ago
function LevelNotify(lvl)
    Player.PlayerGui.LevelNotify.LevelUp:Fire(lvl)
end
function onLevelUp(lvl)
    LVL_HUE = math.clamp(tonumber(lvl), 1, 100) / 100 * 0.8333333333333334
    Info.XP.Bar.Level.Text = "LEVEL " .. lvl
    Info.XP.Bar.BackgroundColor3 = Color3.fromHSV(LVL_HUE, 1, 0.19607843137254902)
    Info.XP.Bar.Fill.BackgroundColor3 = Color3.fromHSV(LVL_HUE, 1, 1)
end
Database.Notify.OnClientEvent:connect(function(action, ...)
    local vars = {
        ...
    }
    if action == "new tp" then
        onPointsAdded(vars[1])
    elseif action == "new level" then
        onLevelUp(vars[1])
        LevelNotify(vars[1])
    elseif action == "new xp" then
        onXPChange(vars[1])
    end
end)
onLevelUp(sendControl("get level"))
onPointsAdded(sendControl("get tp"))
onXPChange(sendControl("get xp"))

Im trying to make it so it doesnt loop, it only does the lvlnotify fire each time ur at a new level.

1 answer

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

I dont know whats wrong with your script would need more info but this is what i use and its much much better, you can change the xpp required whenever and ittl auto update for the players. the function should be in a module returns a table and you can get the data by doing tbl[1] or tbl[2] or tbl[3] from the returned side

module.get_rank = function(name)
    local wins = --Players wins
    local req = module.start_wins
    local inc = module.wins_increase
    local rank = 0
    repeat
        if wins >= req then
            wins = wins - req
            req = req + inc
            rank = rank + 1
        end
    until wins < req
    local tbl = {rank, wins, req}
    return tbl
end
0
and then have a remote update the client side for all stats instead of 1 remote per stat Vetrodex 22 — 3y
0
it should update whenever theres an xp change or anything Vetrodex 22 — 3y
0
doesnt have to be in a module tho but its just better there Vetrodex 22 — 3y
Ad

Answer this question