Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i Add KnockBack to this attack script?

Asked by
Roguzy 2
4 years ago

this is a Heavy attack script and by that i mean when they want to finish a combo the player uses this attack and it should Knock the player back a few blocks but i have no idea how to go about this so any help would be appreciated heres the code

Enabled = true Combo = 1 script.Parent.OnServerEvent:connect(function(Player, Action, V1) local c = Player.Character if Enabled == false then return end if Action == "Combat" then Enabled = false if Combo == 1 then -- if player presses the button once the animation will play

        local Track = Instance.new("Animation")
        Track.AnimationId = "rbxassetid://4804402067"
        local Anim = c.Humanoid:LoadAnimation(Track)
        Anim:Play()

    wait(0.5) -- this is the amount of time it takes for the animation to reach the punch i put this here so the damage would happen when the animation reaches the punch

    local Region = Region3.new(V1-Vector3.new(2,2,2),V1+Vector3.new(2,2,2))
    local RTable = workspace:FindPartsInRegion3(Region, nil, 20)
    for i,v in pairs(RTable) do
        if v.Parent:findFirstChild("Humanoid") and v.Parent:FindFirstChild("Deb") == nil and v.Parent ~=c then
            local Deb = Instance.new("BoolValue", v.Parent)
            Deb.Name = "Deb"
            game.Debris:AddItem(Deb,0.2)
                v.Parent.Humanoid:TakeDamage(7)

--if want to insert the knock back here but i have little to no idea on how to go about this help please!!

           end
       end
    end
    wait(0.2)
    Enabled = true
end

end)

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

Here's Just an idea. Use a bodyforce for a couple seconds to achive this. You can use Z to go backwards. Just experiment until you get the thing you wanted!

forward = -1 backward = 1

0
thank you Roguzy 2 — 4y
Ad

Answer this question