Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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().

This discussion is preserved as it was. New answers, comments, and votes are closed.