I have a script that flings your character when you die. The problem is, I want the person being killed to fly away from the direction that the killer is looking. I already know how to find who killed the person (which is why i'm looking for the killer on line 25) and how to find where the killer is looking, but i'm confused on how to make the player fling away from the killer.
local Humanoid
while not Humanoid do
wait()
Humanoid = script.Parent:FindFirstChildWhichIsA("Humanoid")
end
function Fling()
if Humanoid and Humanoid.Parent then
local attackerpos = Humanoid:FindFirstChild("killer").Character.HumanoidRootPart.CFrame.lookVector -- finding out the direction that the player is looking
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = Humanoid.Parent.UpperTorso
BodyVelocity.Velocity = Vector3.new(0, 0, 0) --this is what i need to change
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
wait(0.1)
BodyVelocity:Destroy()
end
end
Humanoid.Died:connect(function()
if Humanoid:FindFirstChild("killer")then --finding the killer's player from a ObjectValue
Fling()
end
end)
Any help would be greatly appreciated.
