#parry test wont work

1 messages · Page 1 of 1 (latest)

silk gull
#

it should prints out "parried" if my parry hitbox (the green one) touches the attack hitbox ("the red one)

#

--parry script:

local userinputservice = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

if not humanoid:FindFirstChild("Animator") then
Instance.new("Animator").Parent = humanoid
end
local animator = humanoid:WaitForChild("Animator")

-- Load animation
local parryanim = script:WaitForChild("parry anim")
local parryanimTrack = animator:LoadAnimation(parryanim)

local cframe = script.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(0, 0, 0))
local size = Vector3.new(6 , 5, 4)

local currentmob = game.Workspace:WaitForChild("currentmob")

#

userinputservice.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
parryanimTrack:Play()
parryanimTrack.Priority = Enum.AnimationPriority.Action3
warn("Parry animation played!")
end
end)

parryanimTrack:GetMarkerReachedSignal("parry1"):Connect(function()
print("Parry 1 marker reached!")

local parryhitbox = Instance.new("Part")
parryhitbox.Anchored = false
parryhitbox.CanCollide = false
parryhitbox.CanQuery = true
parryhitbox.CanTouch = false
parryhitbox.Massless = true
parryhitbox.CFrame = script.Parent.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(0, 0, 0))
parryhitbox.Size = Vector3.new(6, 5, 4)
parryhitbox.BrickColor = BrickColor.new("Sea green")
parryhitbox.Transparency = 0.75
parryhitbox.Parent = workspace

local weld = Instance.new("WeldConstraint")
weld.Part0 = script.Parent:WaitForChild("HumanoidRootPart")
weld.Part1 = parryhitbox
weld.Parent = script.Parent




local params = OverlapParams.new()
params.FilterDescendantsInstances = {parryhitbox, script.Parent, currentmob}

local somethingtouchedparryhitbox = workspace:GetPartBoundsInBox(cframe, size, params)


    for i, part in ipairs(somethingtouchedparryhitbox) do
        if part.Parent.IsDescendantOf(game.Workspace:WaitForChild("parriable attacks")) then --parriable attacks is a folder
        --if part.Name == "HITBOXATTACK" then
            print("parried")

        end
    end



parryanimTrack:GetMarkerReachedSignal("parry2"):Connect(function()
    parryhitbox:Destroy()
end)

end)

#

--attack script

local animator = script.Parent:WaitForChild("Humanoid"):WaitForChild("Animator")

local attackanim = script:WaitForChild("attackanim")
local attackanimTrack = animator:LoadAnimation(attackanim)

local range = script.Parent:WaitForChild("range")
local vfx = script.Parent:WaitForChild("vfx"):WaitForChild("vfxparry")

local player = game:GetService("Players")
local mobs = game.Workspace:WaitForChild("currentmob")

local playerhitted = {}

range.Touched:Connect(function(somethingtouchedrange)
if somethingtouchedrange.Parent:FindFirstChild("Humanoid") and player:GetPlayerFromCharacter(somethingtouchedrange.Parent) then

    if somethingtouchedrange.Parent:FindFirstChild("Humanoid").Health > 0 and not table.find(playerhitted, somethingtouchedrange.Parent) then
        table.insert(playerhitted, somethingtouchedrange.Parent)
        attackanimTrack:Play()
        attackanimTrack.Priority = Enum.AnimationPriority.Movement
        
        task.wait(5)
        table.clear(playerhitted, somethingtouchedrange.Parent)
    end
end

end)

attackanimTrack:GetMarkerReachedSignal("vfxparrystart"):Connect(function(vfxparryhasstarted)
if vfxparryhasstarted then
print("vfxparry started")
vfx:Emit(1)
end
end)

attackanimTrack:GetMarkerReachedSignal("punch1"):Connect(function(punch1hasstarted)
if punch1hasstarted then
print("hitbox script has started")
local zomcframe = script.Parent.HumanoidRootPart.CFrame *

#

CFrame.new(Vector3.new(0, 0, -4))
local hitboxsize = Vector3.new(9, 9, 8)

    local hitbox = Instance.new("Part")
    hitbox.Anchored = true
    hitbox.CanCollide = false
    hitbox.CanQuery = true
    hitbox.CanTouch = false
    hitbox.Size = hitboxsize
    hitbox.CFrame = zomcframe
    hitbox.BrickColor = BrickColor.new("Really red")
    hitbox.Transparency = 0.75
    hitbox.Parent = workspace:WaitForChild("parriable attacks")
    hitbox.Name = "HITBOXATTACK"
    
    local params = OverlapParams.new()
    params.FilterDescendantsInstances = {hitbox, mobs}
    
    
    local somethingtouchedhitbox = workspace:GetPartBoundsInBox(zomcframe, hitboxsize, params)

    
    
    local hitchar = {}
    for i, part in pairs(somethingtouchedhitbox) do
        if part.Parent:FindFirstChildOfClass("Humanoid") and not table.find(hitchar, part.Parent) then
            table.insert(hitchar, part.Parent)
            print(part.Parent.Name)
            part.Parent:WaitForChild("Humanoid").Health -=10
            
            
            part.Parent:SetAttribute("stunned", true)
            print("set part parent stun to true")
            task.wait(2)
            part.Parent:SetAttribute("stunned", false)
            print("set part parent stun to false")
            
            --[[task.spawn(function()
                part.Parent:WaitForChild("Humanoid").WalkSpeed = 4
                task.wait(3)
                part.Parent:WaitForChild("Humanoid").WalkSpeed = 10
            end)]]
        end
    end

    task.delay(0.25, function()
        hitbox:Destroy()
        print("hitbox has been destroyed")
    end)    
end

end)