the hitbox doesn't damage instantly so that is a problem for me, here is the code:
(local bF = script:WaitForChild("Function")
bF.OnInvoke = function()
if not M1Debounce then
M1Debounce = true
local punchsd = script.Parent.Parent:FindFirstChild("Punch")
punchsd:Play()
local hitbox = Instance.new("Part")
hitbox.Material = "ForceField"
hitbox.Transparency = 0.3
hitbox.Color = Color3.fromRGB(255, 0, 0)
hitbox.Massless = false
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Size = Vector3.new(4, 5.339, 2.613)
hitbox.Parent = workspace
hitbox.CFrame = script.Parent.Parent:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0, 0, -5)
m1preformed += 1
currentM1 += 1
local correspondingM1Anim = rsanim:FindFirstChild('Punch ('..currentM1..')')
local M1Track = animator:LoadAnimation(correspondingM1Anim)
M1Track:Play()
hitbox.TouchEnded:Connect(function(otherpart)
local parent = otherpart.Parent
-- Ensure the parent object has Attributes property
local attributes = parent:FindFirstChild("Attributes")
-- Check if Attributes contains the specified values
local blocking = attributes:FindFirstChild("Blocking")
local blockbar = attributes:FindFirstChild("Blockbar")
-- Check if Attributes properties exist
local blockingValue = blocking.Value
local blockbarValue = blockbar.Value
local humanoid = parent:FindFirstChildOfClass("Humanoid")
-- Ensure hitbox is not affecting the player or specific parts
local value = tonumber(blockbar.Value)
-- Handle Blocking = "On"
if parent.Name == plrname then return end
if blockingValue == "On" then
if value and (value < 0 or value == 0) then
blocking.Value = "Off"
hitbox:Destroy()
elseif blockbarValue ~= 0 then
blockbar.Value = blockbar.Value-dmg
hitbox:Destroy()
end
-- Handle Blocking = "Parry"
elseif blockingValue == "Parry" then
script.Enabled = false
script.Parent.Parent:WaitForChild("HumanoidRootPart").Anchored = true
hitbox:Destroy()
task.wait(1)
script.Parent.Parent:WaitForChild("HumanoidRootPart").Anchored = false
script.Enabled = true
-- Handle Blocking = "Off"
elseif blockingValue == "Off" then
humanoid:TakeDamage(dmg)
hitbox:Destroy()
wait(0.4)
else
print("Invalid blocking value")
hitbox:Destroy()
return
end
end)
task.wait(M1Track.Length -0.1)
task.spawn(function()
local OldM1Preformed = m1preformed
task.wait(waitBeforeReset)
if OldM1Preformed == m1preformed then
currentM1 = 0
end
end)
if currentM1 == 4 then
task.wait(comboEndCooldown)
currentM1 = 0
end
M1Debounce = false
end
end)
please help
** You are now Level 2! **