How to make debounce for multiple local script

Is there any ways to make a debounce for multiple local script like make a boolvalue and when the value is false all local script that use the this boolvalue for it’s debounce

i’m not good at explaining so here’s what i mean
Ca1111111111pture
yeah :sunglasses:


local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRoot = Character:WaitForChild("HumanoidRootPart")
local wall = nil


local debounce = game.ReplicatedStorage:WaitForChild("Debounce"):WaitForChild("debounce").Value
local CombatRemote = script:WaitForChild("RemoteEvent")
local Anims = game:GetService("AnimationClipProvider")
local CS = game:GetService("CollectionService")
local TS = game:GetService("TweenService")
local SkillRemote = script:WaitForChild("Skill")
local debounceRemote = script:WaitForChild("E1")

local combo = 1
local lasthit = 0
local CD = 0.25
local CD1 = 0.25
local CanAir = 1
---------------------------------------

local MDotP
---------------------------------------

local Mouse = Player:GetMouse()
---------------------------------------

local SPCAEKEYDOWN = false
local WKeyDown = false
local AKeyDown = false
local SKeyDown = false
local DKeyDown = false
---------------------------------------

local M1CoolDown = 1
---------------------------------------



local Slow_Time = 0.5

local SkillCoolDown1 = 1
local SkillCoolDown2 = 1
local SkillCoolDown3 = 1
local SkillCoolDown4 = 1
local SkillCoolDown5 = 1

local HoldSkill123 = false

local Previous_Key = "" 
local Previous_Fall = "" 

local UIS = game:GetService("UserInputService")
local keys = {}

local MPH = (HumanoidRoot.Position - Mouse.Hit.Position).Magnitude

local Barrage
local CD_Barrage = 1
local SkillCD = 1
local OI1 = Humanoid:LoadAnimation(game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Katakuri"):WaitForChild("Roll"))
local OIRight = Humanoid:LoadAnimation(game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Katakuri"):WaitForChild("Left"))
local OILeft = Humanoid:LoadAnimation(game.ReplicatedStorage:WaitForChild("Animations"):WaitForChild("Katakuri"):WaitForChild("Right"))
local R_in
local L_in
local R_out
local L_out

local Combat_Anim = {
	script.Parent:WaitForChild("Anims"):WaitForChild("A1"),
	script.Parent:WaitForChild("Anims"):WaitForChild("A2"),
	script.Parent:WaitForChild("Anims"):WaitForChild("A3"),
	script.Parent:WaitForChild("Anims"):WaitForChild("A4"),
	script.Parent:WaitForChild("Anims"):WaitForChild("A5"),
	script.Parent:WaitForChild("Anims"):WaitForChild("A6")
}

local Air = {
	game.ReplicatedStorage.Animations.Air2.Animation2,
	script.Parent:WaitForChild("Anims"):WaitForChild("Slam")
	
}

local BlockCD = 1

SkillRemote:FireServer("Pole")


if Humanoid.Health > 0 and not Character:FindFirstChild("KKK111") and debounce == false then

	if not Character:FindFirstChild("Stun") and debounce == false and Humanoid.Health > 0 and not Character:FindFirstChild("KKK111") then
		
		UIS.InputBegan:Connect(function(Input,IsTyping)
			
			if not IsTyping then
				
				if Input.KeyCode == Enum.KeyCode.F then
					
					script:WaitForChild("E1"):FireServer("DF")
					
					
				end
				
			end
			
		end)
		
		UIS.InputBegan:Connect(function(Input,IsTyping)

			if not IsTyping then

				if Input.UserInputType == Enum.UserInputType.MouseButton1 then
					if tick() - lasthit > 1 then
						combo = 1
						Previous_Key = "" 
						
					end
					lasthit = tick()
					

					
					if M1CoolDown == 1 and not debounce and not Character:FindFirstChild("KKK111") and not Character:FindFirstChild("Stun") and Humanoid.Health > 0 then
						if combo == 6 and CanAir == 1 then
							Humanoid:LoadAnimation(Combat_Anim[combo]):Play(0.1, 1, 2)
							M1CoolDown = 2
							debounceRemote:FireServer("DT")

							debounce = true
							Previous_Key = ""
							CombatRemote:FireServer('M1_Combo_End',Vector3.new(5.48, 4.971, 4.019),HumanoidRoot.CFrame * CFrame.new(0,0,-1.8))
							combo = 1
							wait(CD)
							debounce = false
							debounceRemote:FireServer("DF")

							wait(2)
							M1CoolDown = 1
						elseif combo == 6 and CanAir == 2 then

							Humanoid:LoadAnimation(Air[2]):Play(0.1, 1, 2)
							M1CoolDown = 2
							debounceRemote:FireServer("DT")

							debounce = true
							Previous_Key = ""
							CombatRemote:FireServer('M1_Slam',Vector3.new(7.701, 4.952, 7.482),HumanoidRoot.CFrame * CFrame.new(0,0,-2.5))
							combo = 1
							wait(CD)
							debounce = false
							debounceRemote:FireServer("DF")

							wait(2)
							M1CoolDown = 1
						elseif combo == 5 and SPCAEKEYDOWN == true and CanAir == 1 then
							if Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
								
								Humanoid:LoadAnimation(Air[1]):Play(0.1, 1, 2)
								debounceRemote:FireServer("DT")

								debounce = true
								Previous_Key = "L"
								delay(0.85,function()
									
									combo = 1
									
								end)
								CanAir = 2
								CombatRemote:FireServer('M1_Uptilt',Vector3.new(5.48, 4.971, 4.019),HumanoidRoot.CFrame * CFrame.new(0,0,-1.8))
								wait(CD + 0.25)
								debounce = false
								debounceRemote:FireServer("DF")
								
							end
						else
							if CanAir == 1 then

								Humanoid:LoadAnimation(Combat_Anim[combo]):Play(0.1, 1, 2)
								debounceRemote:FireServer("DT")

								debounce = true
								Previous_Key = "L"
								combo = combo + 1
								CombatRemote:FireServer('M1_Combo_Start',Vector3.new(5.48, 4.971, 4.019),HumanoidRoot.CFrame * CFrame.new(0,0,-1.8))
								wait(CD)
								debounce = false
								debounceRemote:FireServer("DF")

								
							elseif CanAir == 2 then
								if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
									
									Humanoid:LoadAnimation(Combat_Anim[combo]):Play(0.1, 1, 2)
									debounceRemote:FireServer("DT")

									debounce = true
									Previous_Key = "L"
									combo = combo + 1
									CombatRemote:FireServer('M1_Combo_OnAir',Vector3.new(7.701, 4.952, 7.482),HumanoidRoot.CFrame * CFrame.new(0,0,-2.5))
									wait(CD)
									debounce = false
									debounceRemote:FireServer("DF")
									
									
								end
								
							end


						end



					end	
				end

			end

		end)

	end
end



game:GetService("RunService").RenderStepped:Connect(function()
	if UIS:IsKeyDown(Enum.KeyCode.W) then
		WKeyDown = true
	else 
		WKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.A) then
		AKeyDown = true
	else 
		AKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.S) then
		SKeyDown = true
	else 
		SKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.D) then
		DKeyDown = true
	else 
		DKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.Space) then
		SPCAEKEYDOWN = true
	else
		SPCAEKEYDOWN = false
	end

end)

Humanoid.StateChanged:Connect(function(old,new)

	if new == Enum.HumanoidStateType.Landed then
		M1CoolDown = 2
		CanAir = 1
		wait(2)
		M1CoolDown = 1
		
	end

end)

I think something like this can work

local GlobalBool = VALUE LOCATION HERE

--And then a "local" bool value here
trueFalseValue = nil
value:GetPropertyChangedSignal("Value"):Connect(function()
        trueFalseValue = GlobalBool.Value
   
end)

If you then have a check for trueFalseValue in both scripts i think it will work

You can also just do this i think?

local GlobalBool = VALUE LOCATION HERE

if GlobalBool.Value == false then
--Code here
end

I’m a little confused can you explain more like what value to place at value location or something like that,(Sorry that i replied late :face_holding_back_tears:)

Remove the .Value from your variable because it will use the current value. Leave it as the instance, and not the value so you can call it later.

local debounce = game.ReplicatedStorage:WaitForChild("Debounce"):WaitForChild("debounce")--.Value (remove this .Value)

For the rest of the script that calls for the value, you call it and set it by

debounce.Value == 

or

debounce.Value =

Thanks a lot :)) :sunglasses: :sunglasses: :sunglasses:
(30
Cha
racterssssssssssssss)

1 Like