i currently have a problem with my parry system, here’s the script:
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local block = hum:LoadAnimation(ReplicatedStorage.Assets.Animations.Block)
local mouse = player:GetMouse()
local DB = false
local istool = false
local parryre = ReplicatedStorage.Assets.Events.Parry
local rs = game:GetService("RunService")
local function onToolEquipped(tool)
UIS.InputBegan:Connect(function(input, gameprocessed)
if not gameprocessed then
if input.UserInputType == Enum.UserInputType.MouseButton2 then
if istool then
if not DB then
DB = true
parryre:FireServer()
wait(2)
DB = false
end
end
end
end
end)
end
char.ChildAdded:Connect(function(newChild)
if newChild:IsA("Tool") then
istool = true
onToolEquipped(newChild)
end
end)
char.ChildRemoved:Connect(function()
istool = false
end)
the problem is a bit hard to explain but, to sum it up whenever i unequip a tool and spam the parry input. when i equip a tool again and parry again it spams the parry animation
here’s a video of the problem:
(sorry for the poor quality)
robloxapp-20240618-1254525.wmv (817.5 KB)
(i only pressed the parry input when i equipped the sword the first time and when i unequipped the sword)
I tried solving this myself but it ended up creating more problems so any help is appreciated.
thank you.