So while I was scripting a simple combat system I found a bug were if I m1 and press F at the same time 2 scripts would conflict with each other Im really new to scripting so I have no Idea what to do. I tried filling in stuff with AI but I have no Idea what im doing. Can someone help
This is the script that handles the M1ing and the other script is the one that handles the blocking:
local Tool=script.Parent
local Player=game.Players.LocalPlayer
local Char=game.Workspace:WaitForChild(Player.Name)
local Humanoid=Char:WaitForChild("Humanoid")
local Check=0
local Enable=true
local normalWalkSpeed=16
local reducedWalkSpeed=5
local normalJumpPower=50
local reducedJumpPower=0
-- Function to temporarily reduce walk speed and jump power simultaneously
local function reduceWalkAndJumpPower(duration)
Humanoid.WalkSpeed = reducedWalkSpeed
Humanoid.JumpPower = reducedJumpPower
wait(duration)
Humanoid.WalkSpeed = normalWalkSpeed
Humanoid.JumpPower = normalJumpPower
end
Tool.Activated:Connect(function()
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
if not Enable then return end
Enable = false
-- 🛑 Disable the Blocking script for 0.5 seconds
local blockingScript = Tool:FindFirstChild("Blocking")
if blockingScript then
blockingScript.Disabled = true
delay(0.5, function()
blockingScript.Disabled = false
end)
end
if Check == 0 then
humanoid:LoadAnimation(script.Anim01):Play()
script.Parent.Combo.C0:FireServer(script.Parent.Handle)
script.Swing:Play()
script.Parent.Handle.Blade.Trail.Enabled = true
reduceWalkAndJumpPower(0.55)
script.Parent.Handle.Blade.Trail.Enabled = false
Check = 1
elseif Check == 1 then
humanoid:LoadAnimation(script.Anim02):Play()
script.Parent.Combo.C1:FireServer(script.Parent.Handle)
script.Swing:Play()
script.Parent.Handle.Blade.Trail.Enabled = true
reduceWalkAndJumpPower(0.55)
script.Parent.Handle.Blade.Trail.Enabled = false
Check = 2
elseif Check == 2 then
humanoid:LoadAnimation(script.Anim03):Play()
script.Parent.Combo.C2:FireServer(script.Parent.Handle)
script.Swing:Play()
script.Parent.Handle.Blade.Trail.Enabled = true
reduceWalkAndJumpPower(0.55)
script.Parent.Handle.Blade.Trail.Enabled = false
Check = 3
elseif Check == 3 then
humanoid:LoadAnimation(script.Anim04):Play()
script.Parent.Combo.C3:FireServer(script.Parent.Handle)
script.Swing:Play()
script.Parent.Handle.Blade.Trail.Enabled = true
reduceWalkAndJumpPower(0.55)
script.Parent.Handle.Blade.Trail.Enabled = false
Check = 4
elseif Check == 4 then
humanoid:LoadAnimation(script.Anim05):Play()
script.Parent.Combo.C4:FireServer(script.Parent.Handle)
script.Swing:Play()
script.Parent.Handle.Blade.Trail.Enabled = true
reduceWalkAndJumpPower(2.5) -- Longer duration for the last combo
script.Parent.Handle.Blade.Trail.Enabled = false
Check = 0
end
Enable = true
end)
-- Reset the combo if no action happens within 10 seconds
while wait(10) do
if Check == 1 then
Check = 0
end
end