ApplyImpulse Not working

I’m trying to make a wall jump system that’s mostly on the client. I’m firing a remoteEvent to applyImpulse to the player’s HumanoidRootPart.

Client
function wallJump()
	exitingWall = true
	exitingWallTimer = exitingWallTime
	local wallNormal = nil

	if rightWallHit ~= nil then
		wallNormal = rightWallHit.Normal
	elseif leftWallHit ~= nil then
		wallNormal = leftWallHit.Normal
	end

	if wallNormal ~= nil then
		local forceToApply = hrp.CFrame.UpVector * wallJumpUpForce + wallNormal * wallJumpSideForce

		events.ModifyAssemblyLinearVelocity:FireServer(hrp, Vector3.new(hrp.AssemblyLinearVelocity.X, 0, hrp.AssemblyLinearVelocity.Z))
		events.ApplyImpulseToAssembly:FireServer(hrp, forceToApply)
		print("Wall Jump Applied with Force: ", forceToApply)
	end
end
Server
local events = game.ReplicatedStorage:WaitForChild("Events")

-- Function to apply impulse to the character's Assembly part
function applyImpulseToAssembly(setter, assemblyPart, impulseForce)
	-- Check if the assemblyPart and impulseForce are valid
	if assemblyPart and assemblyPart:IsA("BasePart") and impulseForce then
		-- Print debug information to verify correct force application
		print("Server received ApplyImpulse event.")
		print("Impulse Force:", impulseForce)

		-- Ensure that the assemblyPart belongs to the player
		local character = setter.Character
		if  assemblyPart:IsDescendantOf(character) then
			assemblyPart:ApplyImpulse(impulseForce)
		else
			warn("Invalid assemblyPart for player: ", setter)
		end
	else
		warn("Invalid parameters passed to ApplyImpulseToAssembly.")
	end
end

-- Function to modify the assembly's linear velocity
function modifyAssemblyLinearVelocity(setter, assemblyPart, assemblyVector3)
	if assemblyPart and assemblyPart:IsA("BasePart") and assemblyVector3 then
		print("Server received ModifyAssemblyLinearVelocity event.")
		print("New Velocity Vector:", assemblyVector3)

		-- Ensure that the assemblyPart belongs to the player
		local character = setter.Character
		if character and assemblyPart:IsDescendantOf(character) then
			assemblyPart.AssemblyLinearVelocity = assemblyVector3
		else
			warn("Invalid assemblyPart for player: ", setter)
		end
	else
		warn("Invalid parameters passed to ModifyAssemblyLinearVelocity.")
	end
end

-- Connect the server functions to the events
events.ApplyImpulseToAssembly.OnServerEvent:Connect(applyImpulseToAssembly)
events.ModifyAssemblyLinearVelocity.OnServerEvent:Connect(modifyAssemblyLinearVelocity)

I’ve looked for solutions online but none of them are helping. Any help would greatly be appreciated!

It seems as that you aren’t passing through the impulseForce.

The client seems to send 2 arguments.
events.ApplyImpulseToAssembly:FireServer(hrp, forceToApply)

While the function seems to take 3 arguments, which is missing the #3 argument.
function applyImpulseToAssembly(setter, assemblyPart, impulseForce)

No, b/c when clients fire a remoteEvent, the first argument is the client who fired it

Oh, that’s my bad. I didn’t know setter was a Player.

1 Like

You’re having an NetworkOwnership issue; Your character model has a NetworkOwner of the client by default and so when you call

-- ServerSide
if  assemblyPart:IsDescendantOf(character) then
	-- assemblyPart has a NetworkOwnership of Client
	assemblyPart:ApplyImpulse(impulseForce) -- Server tries to Apply an Impulse; This doesn't pass thru the Server-Client boundary and thus the client never see's this
	-- Client then Updates the server physics for the character, and never includes your Impulse because it never saw it
else
	warn("Invalid assemblyPart for player: ", setter)
end

If you apply the impulse on the client side your code will work exactly as intended

Alternatively you can override this by

Character:SetNetworkOwner(nil) -- Forcing the server to take NetworkOwnership

The Client-Server boundary is probably why this worked just fine for everything that wasn’t your character.

1 Like

Thank you so much! It’s working now

1 Like