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
#Issues with applying a knock velocity to players
1 messages · Page 1 of 1 (latest)
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
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
yeah i thought i could just give the client control and let them do it then do an anti cheat thing
** You are now Level 1! **
is that the only workaround?
also would it work if the ownership is shared between clients
I don't think u can share ownsership
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
isnt that the hitbox turning red
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
oh
if u don't wanna change network ownership then maybe
add a velocity to every character beforehand
and enable it when theyre hit
like bodyvelocity?
maybe change all the parts to massless too to make the velocity act faster
one of these 2 i think
body velocity is deprecated
has a big delay at the start and doesnt really work on players
just apply the impulse on the client for players
Thats how I did knockback with ApplyImpulse
yeah thats what i opted for thanks