Velocity Killing Player

So I have a slap tool and it flings and ragdolls the player but sometimes it kills them. I saw this bug occur with someone else as well but I don’t know how they managed to fix it. I am assuming it has something to do with the linear velocity but can someone guide me on this?

– Force code

function Service.ApplySlapForce(data: slapData, character: Model, slapTool: SlapTool)
	local force = data.FLING_FORCE
	local plrHRP: Part = character:FindFirstChild("HumanoidRootPart")
	local vectorData = data.VECTOR

	local onTouch
	local debounce = {}

	onTouch = slapTool.Hitbox.Touched:Connect(function(hit)
		if debounce[hit] then return end
		debounce[hit] = true

		if hit.Parent == character then return end
		if hit.Parent:HasTag("Character") then warn("CHAR") return end

		local hrp: Part = hit.Parent:FindFirstChild("HumanoidRootPart")
		if not hrp then return end

		local attachment = Instance.new("Attachment", hrp)

		local linVelo = Instance.new("LinearVelocity")
		linVelo.Attachment0 = attachment
		linVelo.VectorVelocity = plrHRP.CFrame.LookVector * vectorData.X + Vector3.new(0, vectorData.Y)
		linVelo.MaxForce = 9999
		linVelo.Parent = hrp

		task.spawn(function()
			hit.Parent:SetAttribute("Ragdoll", true)
			task.delay(2, function()
				hit.Parent:SetAttribute("Ragdoll", false)
			end)
		end)

		Debris:AddItem(linVelo, 0.2)
	end)

	task.delay(0.2, function()
		if onTouch then onTouch:Disconnect() end
	end)
end
1 Like

Try using BasePart:ApplyImpulse() instead, it’ll probably act more like a ‘slap’ like you’re hoping and be more consistent with not killing players.