So if you click a Text Button then it will give you "Pet Stats" and when you click a part it gives you money * the "Pet Stats" and when you click the Text Button it will give you 2 pet stats and equip the pet and makes the Text Button invisble but if you auto click or click it really fast then it will give you like 4 or 6 pet stats does anybody know how to fix this so it will only give you 2 pet stats even if you auto click
here is my script:
local EquipButton = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Pet = ReplicatedStorage:WaitForChild("CubePet")
local PetStats = game.Workspace.PetStats
EquipButton.MouseButton1Click:Connect(function()
Pet.Parent = game.Workspace
EquipButton.Visible = false
PetStats.Value += 2
end)
Try this, maybe you didn't use debounce properly.
local EquipButton = script.Parent local ReplicatedStorage = game:GetService("ReplicatedStorage") local Pet = ReplicatedStorage:WaitForChild("CubePet") local PetStats = game.Workspace.PetStats local Debounce = false EquipButton.MouseButton1Click:Connect(function() if not Debounce then Debounce = true Pet.Parent = game.Workspace EquipButton.Visible = false PetStats.Value += 2 task.wait(3) Debounce = false end end)