Broken Debounce

Im making a script and when you say the word you grow bigger but the debounce are messing it up can get bigger multiple times breaking the game .

i tried repositioning the debounce But then when one player does it another one has to wait for the debounce .

ts = game:GetService("TweenService")

goal1 = {}
goal1.Transparency = 1

goal2 = {}
goal2.Transparency = 0

tweenInfo = TweenInfo.new(1)

local db = false

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		
		if db then return end
		db = true
		
		local Humanoid = Character:WaitForChild("Humanoid")
		local face = Character.Head.face
		Player.Chatted:Connect(function(msg)

			if msg == "maior" then
				
				for _,v in pairs(Character:GetDescendants()) do
					if (v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal")) then
						if v.Name ~= "HumanoidRootPart" then 
							ts:Create(v, tweenInfo, {Transparency = 1}):Play()
						end
					end
				end

				wait(0.3)

				local HS = Humanoid.HeadScale
				local BDS = Humanoid.BodyDepthScale
				local BWS = Humanoid.BodyWidthScale
				local BHS = Humanoid.BodyHeightScale


				wait(0.3)

				HS.Value =  HS.Value * 3
				BDS.Value = BDS.Value * 3
				BWS.Value = BWS.Value * 3
				BHS.Value = BHS.Value * 3


				for _,v in pairs(Character:GetDescendants()) do
					if (v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal")) then
						if v.Name ~= "HumanoidRootPart" then 
							ts:Create(v, tweenInfo, {Transparency = 0}):Play()
						end
					end
				end

				Humanoid.WalkSpeed = 19
				

				wait(15)


				for _,v in pairs(Character:GetDescendants()) do
					if (v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal")) then
						if v.Name ~= "HumanoidRootPart" then 
							ts:Create(v, tweenInfo, {Transparency = 1}):Play()
						end
					end
				end

				wait(0.6)

				HS.Value =  HS.Value / 3
				BDS.Value = BDS.Value / 3
				BWS.Value = BWS.Value / 3
				BHS.Value = BHS.Value / 3

				Humanoid.WalkSpeed = 16


				for _,v in pairs(Character:GetDescendants()) do
					if (v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Decal")) then
						if v.Name ~= "HumanoidRootPart" then 
							ts:Create(v, tweenInfo, {Transparency = 0}):Play()
						end
					end
				end


				wait(8)
				db = false

			end
		end)
	end)
end)

the debounce has to be a local script

1 Like
local debounce = false

if debounce == false then
       debounce = true
       -- Whatever you add
       wait(5) -- optional
       debounce = false
end)

i tried that and i can do it twice

This is dangerous in securities. Hackers can access local script and remove the debounce.

oh it isnt a local script its a server script inside serverscriptservice

One think I can suggest is that you make a dictionary where each key is a player’s username or UserId, and the value can act as a Boolean value for their own debounce.