How to get NormalID on the raycast

Im create game, like tf2, but i recreate spy and don’t get a NormalId for kill in back.

how i can get NormalId? “Enum.NormalId.Back”

i find only like this:

local function normalIdFromVector(vectors) – this is normal
local epsilon = 0.01
for _, normalId in pairs(Enum.NormalId:GetEnumItems()) do
if vectors.unit:Dot(Vector3.FromNormalId(normalId)) > 1 - epsilon then
return normalId
end
end
end

pls help (sorry a my english…)

Would you like some help with that?

I would use dot product in a way like this for a backstab feature.

local function backstabcheck(a, b)
	local BRoot = b:FindFirstChild("HumanoidRootPart")
	local ARoot = a:FindFirstChild("HumanoidRootPart")

	if not BRoot or not ARoot then
		return false
	end

	local attackDir = (ARoot.Position - BRoot.Position).unit
	local targetLookDir = BRoot.CFrame.LookVector

	local dot = attackDir:Dot(targetLookDir)

	-- adjust the threshold as you'd like (-0.5 to -1 means behind the player)
	return dot <= -0.5
end
2 Likes

bro :broken_heart:

1 Like

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