Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

2 comments

0

You can try using a debounce

0

i already tried that it didnt work

1 answer

✓ Accepted answer

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)

1 comment

0

Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.