Knockback system not working :C

So I am currently creating a knockback system, idk if Im just dumb but the knockback isnt being applied.

Ive put prints into the code and they all print upon being run, yet nothing so far has worked.

function Handler:ApplyKnockback(Knockback: number, Target:BasePart, Direction : Vector3, Params :EffectParameter)
	Params = Params or Handler.newEffectParam()
	
	if Params.ApplyType == 'Target' then
		local Info = {
			Knockback = Direction * 1000000,
			Target = Target,
			StartedAt = Target.Position,
			Params = Params,
			TimeLeft = 0.3,
			Type = 'Knockback'
		}
		
		print(Target)
		table.insert(Effects, Info)
	end
end

-- // Apply Effects //
Iteration += 1

if Iteration == 1 then
	
	-- // Loop //
	RunService.Heartbeat:Connect(function(DeltaTime)
		if #Effects > 0 then
			for _, Effect in Effects do
				
				-- // Knockback
				if Effect.Type == 'Knockback' then
					if Effect.TimeLeft <= 0 then continue end
					
					Effect.TimeLeft -= DeltaTime
					
					print('Applying Knockback')
					Effect.Target:ApplyImpulse(Effect.Knockback)
				end
			end
		end
	end)
end

Now quick question, does the RunContext effect :ApplyImpulse()? Other than that I cant think of why it isnt working lol

Try searching knockback or pushback in the forums. I know there have been quite a few solved posts about this already.

Took a look, a lot of them use other forces, and Id like to use :ApplyImpulse(), as it works much better with the rest of my project.

So did you try raising the force you are using to some really high numbers?
Also put a small vertical force to get the player just off the surface of the ground so that the friction doesn’t affect them too much.

I’d suggest using LinearVelocities, since they’re just far easier to work with and more predictable. Is there a specific reason you’re using ApplyImpulse over LinearVelocity?

Network ownership does. If I run a script on the server to apply force to a part, but my client owns it, the force isn’t applied. It’s very stupid, so basically you would have to apply the knockback on the client and based on which client is giving the knockback.

1 Like

I basically have to update the force every single frame, and using ApplyImpulse makes my life so much easier lol

question, if i were to try to apply the force to a players humanoidrootpart, could i set it’s network owner to nil, apply the force, and then set the network owner back to the player?

yeah but it’d probably be glitchy.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.