So what this does is it checks to see if you backstabbed someone from....behind but its not working for some reason. What i did was i put the code into the Blow function of a sword script i really don't want to explain this code so you will just have to skim through it but the point is the message is not printing.
function dotProduct(a,b)
return a.x*b.x+a.y*b.y+a.z*b.z
end
function blow(hit)
if (hit.Parent == nil) then return end -- happens when bullet hits sword
local humanoid = hit.Parent:findFirstChild("Humanoid")
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
local Torso=humanoid.Torso.Position
local vTorso=vCharacter.Torso.Position
local distance=Torso-vTorso
local normDistance=distance/distance.magnitude
if humanoid~=nil and humanoid ~= hum and hum ~= nil then
-- final check, make sure sword is in-hand
local right_arm = vCharacter:FindFirstChild("Right Arm")
if (right_arm ~= nil) then
local joint = right_arm:FindFirstChild("RightGrip")
if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player.TeamColor ~= vPlayer.TeamColor then end
local dp = dotProduct(normDistance,humanoid.Torso.CFrame.lookVector)
tagHumanoid(humanoid, vPlayer)
humanoid:TakeDamage(damage)
wait(1)
untagHumanoid(humanoid)
if dp < -0.5 then
local m=Instance.new("Message")
m.Parent=game.Workspace
m.Text="BACKSTAB!!!"
wait(2)
m:Destroy()
end
end
end
end
end
