Is this Possible?

Continuing the discussion from Setting a Body Force to the Direction a Part was Hit by a Player Instead of the Player's Look Vector:

I want to set a part’s body force’s force into the direction a player hit the part. Is it possible to find that? If so how and if not are there any alternatives?

I believe Unit could be what you are looking for here. You might be able to set the body force to something like this:

part.CFrame * (character.HumanoidRootPart.CFrame.LookVector.Unit * 10)
1 Like

Thank you for the help! Sometimes it blasts around me instead of the direction I hit it at but I’m wondering if maybe that’s because I multiplied it more to try to force it farther ahead. Here is the script:

local part = script.Parent 

part.Touched:Connect(function(hit) 
	if hit.Parent:FindFirstChild("Humanoid") then 
		local hum = hit.Parent:FindFirstChild("Humanoid")
		local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
		local character = plr.Character
		local HumanoidRootPart = hit.Parent.HumanoidRootPart
		local velocity = Instance.new("BodyForce", part) 
		velocity.Parent = part
		velocity.Force = part.CFrame * (character.HumanoidRootPart.CFrame.LookVector.Unit * 10) * Vector3.new(200 * plr.HitPower.Value, 20, 200 * plr.HitPower.Value)
		script.Disabled = true
		task.wait(2)
		script.Disabled = false
		velocity:Destroy()
	end
end)

Also for context HP is their hit power which is 0 - 100 depending how much they filled the hit gauge. Is there a better way to make it blast farther and incorporate the hit power value?

sorry for the late reply, but to make it hit farther, multiply the 10 here

local part = script.Parent 

part.Touched:Connect(function(hit) 
	if hit.Parent:FindFirstChild("Humanoid") then 
		local hum = hit.Parent:FindFirstChild("Humanoid")
		local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
		local character = plr.Character
		local HumanoidRootPart = hit.Parent.HumanoidRootPart
		local velocity = Instance.new("BodyForce", part) 
		velocity.Parent = part
		velocity.Force = part.CFrame * (character.HumanoidRootPart.CFrame.LookVector.Unit * 10 * plr.HitPower.Value)
		script.Disabled = true
		task.wait(2)
		script.Disabled = false
		velocity:Destroy()
	end
end)
1 Like

No worries, I appreciate you replying at all! Now sometimes it works but other times it still blasts around me or doesn’t blast at all. I’m not sure why. (While testing my hit power was 100)

Yes it is possible to do that.

1 Like

How do you do it? I also need it to blast farther.