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

Tycoon Dropper's Money Gives Extra Money?!

Asked by
enes223 327 Moderation Voter
7 years ago

I Maked Tycoon And Placed Conveyor But When Part Deletes It Gives Extra Money! Here's Script:

script.Parent.IDK.Touched:connect(function(hit) if hit.Name == "Money" then local plr = game.Players.LocalPlayer plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + script.Parent.WOW.Value hit:Destroy() end end)

Please Fix It! Thanks For Looking!

1 answer

Log in to vote
0
Answered by 7 years ago

You are just missing a debounce. Sometimes the Touched event can fire multiple times for a single part.

01local debounced
02script.Parent.IDK.Touched:connect(function(hit)
03    if not debounced and hit.Name == "Money" then
04        debounced = true
05        local plr = game.Players.LocalPlayer
06        plr.leaderstats.Money.Value =
07            plr.leaderstats.Money.Value + script.Parent.WOW.Value
08        hit:Destroy()
09        debounced = false
10    end
11end)
0
THANK YOU! enes223 327 — 7y
Ad

Answer this question