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

If you click a Text Button it will give you stats but theres a glitch?

Asked by 2 years ago

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)

0
You can try using a debounce salaarkhan1 28 — 2y
0
i already tried that it didnt work iamnotcool235_s 27 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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)

0
Thanks iamnotcool235_s 27 — 2y
Ad

Answer this question