Hello!
So I ran into an issue. I made a block system. But everytime I died while blocking the script just completely breaks and I can’t block anymore.
Note: This script is a local script.
Here’s the script :
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TweenService")
----------------------------------------------------
-- Variables
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local PlayerScripts = Player:WaitForChild("PlayerScripts")
local isUsingBlock = Player:WaitForChild("Weapon"):WaitForChild("WeaponAttacks"):WaitForChild("IsUsingAttack5")
local Animation = Instance.new("Animation", Character)
Animation.Name = "BlockAnimation"
Animation.AnimationId = "rbxassetid://8993539850"
local Animation_Loader = Humanoid:LoadAnimation(Animation)
----------------------------------------------------
-- Values
local Key = "T"
local Debounce = false
local Duration = 3
local DebounceTime = 0.25
----------------------------------------------------
-- Code
for i, tools in pairs(Player.Backpack:GetChildren()) do
if tools:FindFirstChild("IsAnItem") == nil then
UIS.InputBegan:Connect(function(input, typing)
if typing then return end
if input.KeyCode == Enum.KeyCode[Key] and Debounce == false then
Debounce = true
local ToolCodes = tools:FindFirstChild("Main_Attack")
local DashCode = PlayerScripts:WaitForChild("Dash")
local BlockGUI = RS:WaitForChild("BlockGUI"):Clone()
Animation_Loader:Play()
Humanoid.WalkSpeed = 5
Humanoid.JumpPower = 0
Character:FindFirstChild("IsBlocking").Value = true
ToolCodes.Disabled = true
DashCode.Disabled = true
BlockGUI.Parent = HumanoidRootPart
wait(Duration)
Humanoid.WalkSpeed = RS:WaitForChild("CurrentWalkSpeed").Value + Player:WaitForChild("Attributes"):WaitForChild("Speed").Value
Humanoid.JumpPower = 60
ToolCodes.Disabled = false
DashCode.Disabled = false
Animation_Loader:Stop()
BlockGUI:Destroy()
Character:FindFirstChild("IsBlocking").Value = false
isUsingBlock.Value = false
wait(DebounceTime)
Debounce = false
end
end)
end
end
Is there a way I can fix this? Thanks!