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

Why does this not show errors but doesn't do what it is supposed to?

Asked by 7 years ago

this script is supposed to bring up the XP value every second. but it doesnt work what is wrong?

player = game.Players.LocalPlayer
tats = player.Stats
xp = tats.XP

function change()
    wait(1)
    xp.Value = xp.Value + 10
    if xp.Value == 100 then 
    end
end

1 answer

Log in to vote
0
Answered by
Link150 1355 Badge of Merit Moderation Voter
7 years ago
Edited 7 years ago

There are two reasons to your problem.

First, you never call your change() function, so its body is never executed. Secondly, even if you did call your change() function, there is no loop, so it would only be executed once.

player = game.Players.LocalPlayer

local stats = player.stats
local xp = stats.xp

function change()
    while true do -- Infinite loop.
        xp.Value = xp.Value + 10

        if xp.Value == 100 then
            -- Do something.
        end

        wait(1) -- We wait one second and proceed to the next step of the loop.
    end
end


change() -- We call change().
Ad

Answer this question