#Issues with applying a knock velocity to players

1 messages · Page 1 of 1 (latest)

wise sage
#

I'm working on this combat system and it works perfectly except for the knockback, where it sometimes just doesn't actually apply it, sometimes it does, and sometimes it does it then rubberbands the player back to their position
It works perfectly with dummies so ill put a show case how it works for both
video has weird res because i was recording my studio screen and it didnt catch the explorer and what not

#

heres the code responsible

function ServerAxeClass:Knockback(victimCharacter, attackerCharacter)
    local attackerRoot = attackerCharacter:FindFirstChild("HumanoidRootPart")
    local targetRoot = victimCharacter:FindFirstChild("HumanoidRootPart")
    local targetHumanoid = victimCharacter:FindFirstChild("Humanoid")
    
    if not attackerRoot or not targetRoot or not targetHumanoid then return end
    
    local horizontalDirection = (targetRoot.Position - attackerRoot.Position) * Vector3.new(1, 0, 1)
    
    targetRoot:SetNetworkOwner(nil)
    targetHumanoid.PlatformStand = true
    targetHumanoid:ChangeState(Enum.HumanoidStateType.Physics)

    local impulse = (horizontalDirection.Unit + Vector3.new(0, 1.2, 0)).Unit * 100 * targetRoot.AssemblyMass

    targetRoot:ApplyImpulse(impulse)

    task.delay(0.4, function()
        if targetHumanoid then
            targetHumanoid.PlatformStand = false
            targetHumanoid:ChangeState(Enum.HumanoidStateType.Freefall)
            
            local player = Players:GetPlayerFromCharacter(victimCharacter)
            if player then targetRoot:SetNetworkOwner(player) end
            targetHumanoid.EvaluateStateMachine = true
        end
    end)
end
calm pewter
#

its due to the network owner being the servre

#

its the safest but it makes it choppy

#

set it to either the player with the axe or the guy getting kncok backed

#

and u can add some anti cheat or just leave it like that

wise sage
#

yeah i thought i could just give the client control and let them do it then do an anti cheat thing

fluid lynxBOT
#

studio** You are now Level 1! **studio

wise sage
#

is that the only workaround?

#

also would it work if the ownership is shared between clients

calm pewter
#

I don't think u can share ownsership

wise sage
#

if 2 players get close to each other they share ownership to have better collisions

#

i think you see it in the video when the ownership thing turns red

calm pewter
#

isnt that the hitbox turning red

wise sage
#

oh no thats not hit boxee

#

thats the ownership viewer

#

built in roblox

#

Green is my client, white is server and red is shared

#

as for the other play it says server owns him but on his screen he sees his ownership colored

#

network owners down there

calm pewter
#

oh

#

if u don't wanna change network ownership then maybe

#

add a velocity to every character beforehand

#

and enable it when theyre hit

wise sage
#

like bodyvelocity?

calm pewter
#

maybe change all the parts to massless too to make the velocity act faster

#

one of these 2 i think

#

body velocity is deprecated

wise sage
#

ill try that out yeah

#

thank you very much

wise sage
#

has a big delay at the start and doesnt really work on players

red pendant
#

just apply the impulse on the client for players

#

Thats how I did knockback with ApplyImpulse

wise sage