So I have a leadersat in a folder called coins(folder is called Susy) and the issue is with the coins, Once I click on the gui to buy the item it subtracts from the leaderstat value, then as soon as I pick up another coin it adds instead of +1 coin it adds + 11, here is the code for the shop
local plr = game:GetService('Players').LocalPlayer script.Parent.MouseButton1Click:Connect(function() if plr.Susy.Coins.Value > 9 then local clone = game.ReplicatedStorage.GravityCoil:Clone() clone.Parent = plr.Backpack plr.Susy.Coins.Value = plr.Susy.Coins.Value - 5 plr.Susy.Coins.Value -= 5 script.Parent.Parent.BruhV2.Visible = true wait(1) script.Parent.Parent.BruhV2.Visible = false wait(1) script.Parent.Parent.Visible = false script.Parent.Parent.Parent.TextButton.Visible = true script.Parent.Parent.Parent.DISPLAYCOINS.Visible = true else plr.leaderstats.Wins.Value = plr.leaderstats.Wins.Value - 0 script.Parent.Parent.Bruh.Visible = true wait(2) script.Parent.Parent.Bruh.Visible = false end end)
And here is the code for the coin ~~~~~~~~~~~~~~~~~
local player = game.Players.LocalPlayer
script.Parent.Touched:Connect(function(hit) game.Workspace.Misc.CoinPickup:Play() local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then plr.Susy.Coins.Value += 1 script.Parent:Destroy()
end
end)
Ok, I think it might be because your not using debounce, because of this, the coin will detect that multiple parts of the characters body is touching the coin. Try this
local player = game.Players.LocalPlayer local debounce = false script.Parent.Touched:Connect(function(hit) game.Workspace.Misc.CoinPickup:Play() local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then if debounce == false then debounce = true plr.Susy.Coins.Value += 1 script.Parent:Destroy() end end debounce = false end)
I'm not sure if this will help but I hope it does because this happened to me before.
Using debounce will resolve this issue
local player = game.Players.LocalPlayer local db = false script.Parent.Touched:Connect(function(hit) if not db then game.Workspace.Misc.CoinPickup:Play() local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then plr.Susy.Coins.Value += 1 script.Parent:Destroy() end db = true wait(2) db = false -- I think you can remove this line and the wait since it will destroy the part + the script anyway. end end)