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

Why is my dropper script creating two drops instead of one?

Asked by 3 years ago

https://prnt.sc/1qcvxu8 Dropper script

https://prnt.sc/1qcw1rp Purchase script

I am pretty inexperienced in programming and wanted to create a really basic tycoon and had this as my dropper script. When you purchase the dropper, it moves the dropper from server storage to the "objects" model (in the tycoon) and there is an if statement checking if the model's parent is the objects model. Sometimes it works when I test it and sometimes it drops in bursts of two. (By sometimes it works and sometimes it doesn't, I mean sometimes when I test it, it always drops one and other times it will always double drop, not just sometimes it will drop two and other times it will drop one)

I tried a lot of fixes and ended up with this code since I thought the problem could be that the loop is being started more than once, so I made only one loop that runs continuously, but the bug still happens.

Also sorry if my code is messy

0
Do some debugging, see if anything runs twice. It happens all the time with me, its usually a loop or a debounce with the wrong requirements AlexanderYar 788 — 3y
0
I tested by putting a print in the loop and found out that sometimes when I test it, it only prints once before stopping (probably because the dropper starts in workspace and is moved into server storage) but sometimes it just loops forever anyways and when I buy the dropper, it creates another loop... I still have no clue why this happens and why it happens seemingly randomly matthewliu 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I tried moving all of the droppers to server storage, to begin with, instead of having a loop that runs at the start and moves all of them to server storage and the bug was resolved. I still don't have any idea why it was happening or how this fixed it, but I guess my question is answered

Ad

Answer this question