Flinging a player

I’ve been making a magic fighting game and I’ve been trying to add some sort of knock back to the attacks, i just cant seem to be able to apply any force on the player

i tried adding vector force or linear velocity to no success

sample code:

body.Touched:Connect(function(Hit)
if Hit:IsA(“Part”) or Hit:IsA(“MeshPart”) then
if Hit.Parent.Name ~= player.Name then
local EHumanoid = Hit.Parent:FindFirstChild(“Humanoid”)
if EHumanoid then
if disabled == false then
disabled = true
EHumanoid:TakeDamage(30)
local velocity = Instance.new(“VectorForce”)
velocity.Parent = EHumanoid.Parent.HumanoidRootPart
velocity.Force = Vector3.new(0,1000,0)
velocity.RelativeTo = Enum.ActuatorRelativeTo.World
end
end
end
end
end)

on a sidenote i tried using applyimpulse on client, to no effect

1 Like

This post shows how to fling a player How do i make a player fling? - #6 by bongusbingis

1 Like

thing is i tried that to no success

1 Like

Set the HumanoidRootPart’s AssemblyLinearVelocity. It should fling it.

1 Like

doesnt work either for some reason

code:

body.Touched:Connect(function(Hit)
		if Hit:IsA("Part") or Hit:IsA("MeshPart") then
			if Hit.Parent.Name ~= player.Name then
				local EHumanoid = Hit.Parent:FindFirstChild("Humanoid")

				if EHumanoid then
					if disabled == false then
						disabled = true
						EHumanoid:TakeDamage(30)
						EHumanoid.Parent.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0,1000,0)
					end
				end
			end
		end
	end)
1 Like

Are you taking damage too? If not, then it might be your touched event.

damage works, only the fling part doesnt

the linear assembly gets set to 0

Maybe try the Torso/UpperTorso? Maybe that could work.

i have tried that, it doesnt work

i noticed that if i set the linear assembly manualy on the client side it does work (not with a script), the script part doesnt work weirdly enough

Try setting your game to R6 mode then just use “Torso”, i’ve had issues with R15 in the past because some avatar packages dont have certain torso parts, or have too many

Also, it appears you don’t have an actual “disabled” boolean in the script, maybe add “local disabled = false” at the beginning?

this is a snippet of code, there is disabled up there further also ive found a workaround, ive simply used apply impulse. i just didnt notice at first when i used it because turns out my avatar is commically heavy

1 Like