How can I make a player that I touch with the hitbox get pushed foward?

Hello, I’m trying to make a battlegrounds game out of boredom, and I’ve recently encountered an issue that I can’t seem to untangle, I wanted to make the target get pushed whenever they get hit. Unfortunately, It doesn’t work.

I’ve tried the solution from this post:


"Dash Ability (LocalScript) > game.StarterPlayer.StarteplayerScripts"

Hitbox.Touched:connect(function(part)

		if part:FindFirstAncestorOfClass("Model") and part:FindFirstAncestorOfClass("Model").Name ~= lclplr.Name then

			if not part:FindFirstAncestorOfClass("Model"):FindFirstChild("Humanoid") then return end
			if touchedAlready[part:FindFirstAncestorOfClass("Model").Name] then return end

			touchedAlready[part:FindFirstAncestorOfClass("Model").Name] = part:FindFirstAncestorOfClass("Model")



			if canslide == false then

				game.ReplicatedStorage.GiveDamage:FireServer(part:FindFirstAncestorOfClass("Model"), script.Damage.Value)
				
				local lookvector = cam.CFrame.LookVector

				if lookvector then
					game.ReplicatedStorage.pushAttacked:FireServer(lookvector)
				end
				
				coroutine.wrap(function()


					lclplr.Character:WaitForChild("HumanoidRootPart").Anchored = true
			
					wait(0.25)

					lclplr.Character:WaitForChild("HumanoidRootPart").Anchored = false
				end)()

			end

		end

	end)

" GameHandler (ServerScript) > game.ServerScriptService"
rp.pushAttacked.OnServerEvent:Connect(function(player, lookvector)
	
	if lookvector then
		player.Character.HumanoidRootPart.AssemblyLinearVelocity = lookvector * 10000 
	end
	
end)

Demo Video:

External Media

P.S.: The dash itself works, its just that the target doesnt get pushed…

I’ll glady answer in more detail if nicely asked. :smiley: :+1:

Have you tried printing out the lookvector on the server?

You mean, pass the lookvector with the RemoteEvent? I’ll try, hold on.

1 Like

Local:

Server:

It’s already doing that.

I meant as in when the event gets fired have you tried printing anything out. Like the lookvector

Yeah, it’s printing out the lookvector.(on both local and script)

So when the push attack event is called it does what it is meant to or doesn’t?

You mean “Rp event”? If so,
When the RP event fires, the server has a “onServerEvent()” function in it.

try :ApplyImpulse() BasePart | Documentation - Roblox Creator Hub

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