Value Not Changing

local t = game.Players.LocalPlayer.Val.Value
while wait() do
if t >= 0 then
		t = t - 1
		wait(1)
	else 
on = false t = t + 1
 wait(1)
end
end

The value of t isn’t changing. t is a NumberVaule

There are no errors

This looks like it’s in a local script. If you are checking the value from the server, it won’t see the changes.

1 Like

It is checking from the client as well

I think I see the problem. You set the value to a variable, and are changing the variable, not the content of the value object.

Try this:

local t = game.Players.LocalPlayer.Val
while true do
	if t.Value >= 0 then
		t.Value = t.Value - 1
	else 
		on = false
		t.Value = t.Value + 1
	end
	wait(1)
end
2 Likes

It still stays the same value.

In order for this to work you’d have to do t.Value for all the t below wait()

Could you give some more context, then? Maybe a screenshot/video of the object explorer/property window? There is nothing wrong with the code syntax-wise.