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
6 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 6 years ago

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

local debounced
script.Parent.IDK.Touched:connect(function(hit)
    if not debounced and hit.Name == "Money" then
        debounced = true
        local plr = game.Players.LocalPlayer
        plr.leaderstats.Money.Value = 
            plr.leaderstats.Money.Value + script.Parent.WOW.Value
        hit:Destroy()
        debounced = false
    end
end)
0
THANK YOU! enes223 327 — 6y
Ad

Answer this question