NotZylon
(shiesty)
March 30, 2021, 12:58am
#1
Why is this happening?
local damage = player:WaitForChild("Data").Damage
local Strength = player:WaitForChild("Data").Strength
Strength.Changed:Connect(function()
Strength.Value = Strength.Value
end)
damage.Changed:Connect(function()
damage.Value = damage.Value + Strength.Value
end)
Don’t change the Damage or Strength value inside the actual .Changed
event, you’re creating an infinite loop
1 Like
My guess is because of this, you’re firing the Event way too much times every time that gets changed which is resulting in OVER 500,000 CHANGES in a second
NotZylon
(shiesty)
March 30, 2021, 1:06am
#4
Oh, What do i do? Do i put it outside of the .Changed
Event?
NotZylon
(shiesty)
March 30, 2021, 1:07am
#5
How do i prevent this form happening again? Do i move the damage.Value part
You could create a dummy IntValue and detect changes in that and send that to the main IntValue
example
DummyIntValue.Changed:Connect(function()
MainIntValue.Value = DummyIntValue.Value + IntValue.Value
end)
NotZylon
(shiesty)
March 30, 2021, 1:09am
#7
Is there another way other than this?
You could put a debounce inside the .Changed
event but depending on the situation, it could mess up your code if the value being calculated is crucial
NotZylon
(shiesty)
March 30, 2021, 1:16am
#9
I did the other one and it works now thanks, but what happens if the same problem happens again?
As far as I know, the problem shouldn’t occur again unless you’re changing the values quickly (for example, every frame) or changing it inside the .Changed
event.
1 Like