My script is subtracting the Value - 2 every second instead of - 1 and no, no other script is doing - 1 in case someone was curious. I don't know why it is doing this, that is why I am asking for your help!
while wait(1) do for i,v in pairs(game.Players:GetChildren()) do if v:FindFirstChild("PointBooster1") then if v:FindFirstChild("PointBooster1").Value - os.time() > 0 then v:FindFirstChild("DoublePoints").Value = true print(os.time()) print(v:FindFirstChild("PointBooster1").Value - os.time()) v:FindFirstChild("PointBooster1").Value = v:FindFirstChild("PointBooster1").Value - 1 else if v:FindFirstChild("DoublePoints") then v:FindFirstChild("DoublePoints").Value = false end end end end end
Do you guys see anything wrong or know what the problem may be? I print os.time() and it is only printing once every second so I know that isn't the problem, I have no idea why it is doing this, but please HELP! Thanks!
A stylistic note: There is no point to using FindFirstChild
when you aren't actually doing error checking. This means there should be exactly two appearances of it in this excerpt.
Beyond this, it's not possible for this single script to be reducing each by more than one per second.
Are you certain there is only this script running? If you isolate it in a completely new place, does it behave correctly?
Also, an unrelated concern, are you sure your check for the existence of DoublePoints
isn't necessary in the other (time-based) if?
Anyway, here's what I suggest is a cleaned up version, but I see no reason to think that this is causing what you are describing:
while wait(1) do for i,v in pairs(game.Players:GetChildren()) do if v:FindFirstChild("PointBooster1") then if v.PointBooster1.Value > os.time() then v.DoublePoints.Value = true print(os.time()) print(v.PointBooster1.Value ,">", os.time()) v.PointBooster1.Value = v.PointBooster1.Value - 1 else if v:FindFirstChild("DoublePoints") then v.DoublePoints.Value = false end end end end end