Hello.
I am currently attempting to make a script where, as soon as it's value is changed to the negatives, it automatically adds 1 until the value is back at 0. I am using a tool, that per swing lesses 1 from the value. I am attemtping to make it automatically regenerate as soon as a number change is detected and it's below 0. This works, however if the value is below -1 (e.g -5), it will first add one, and then duplicate the addition, and so on. So it would go, -5, then -4, then -2 then 2. I am unsure what is causing this, and, with the script, it is also not changing the Part's Y position.
Here is the script I attempted to make:
local IntValue = script.Parent.PositionY
local KelpPart = script.Parent
IntValue:GetPropertyChangedSignal("Value"):Connect(function()
if IntValue.Value == 0 then
print("Kelp is already at Y value 0, no need to regenerate")
else
if IntValue.Value < 0 then
repeat
wait(5)
IntValue.Value = IntValue.Value + 1 and KelpPart.Position == Vector3.new(KelpPart.Position.X, KelpPart.Position.Y + 1, KelpPart.Position.Z)
print("Regenerated 1")
until
IntValue.Value == 0
end
end
end)
I am quite unsure where the source of this issue is coming from, I am experimenting with these things, and would like some help.
Thanks

2 comments
konnichiwaa! V ;3
hi