Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Avoid upgrading to more than 2x when the game lags problem, please help (?)

Asked by 4 years ago
Edited 4 years ago
script.Parent.Touched:connect(function(Part)
    if Part:FindFirstChild("Cash") then
        Part.Cash.Value = Part.Cash.Value * 2
    end
end)
-- When the game lags the parts are worth millions each due to debounce

Is there a way i can avoid this problem, when i test play i get millions/billions and it's game breaking. I want it so that every single part gets upgraded 2x max and can't be upgraded above 2x (just 2x the part's value). -- Btw this is a upgrader.

1 answer

Log in to vote
0
Answered by
RSASDSA 72
4 years ago
Edited 4 years ago

To fix this you would need to add a debounce. I'm not sure what you mean by blaming the issue on a debounce as your code doesn't seem to have one.

Edit: regarding your comment, I'm still not sure what you're trying to do but you could keep a list of parts that had touched the part, and if a part hadn't touched it before then the effect could be done.

0
db will only make it so some parts that goes through gets multiplied and not all of them (if like 3 or 5 parts go through at the same time) popu2004 42 — 4y
Ad

Answer this question