Hello so I’ve been working on a takedown kill for an upcoming game idea and I have realized a flaw in my code . I need to be facing a certain area for my character to look like he is actually doing the takedown. At the moment my animation looks weird because my character is not facing the right way. How could I potentially fix this?
How it looks so far so you can get a reference on how I could fix this.
local hitbox = script.Parent
local knife = game.StarterPack:FindFirstChild("Knife")
local db = true
hitbox.Touched:Connect(function(hit)
local char = hit.Parent
local hum = char and char:FindFirstChild("Humanoid")
local plr = game.Players:FindFirstChild(char.Name)
if db and hum and plr then
db = false
local KTF = plr:WaitForChild("KTF")
local KT = KTF:FindFirstChild("Takedown")
if KT.Value then
KT.Value = false
game.ReplicatedStorage.TakedownCam:FireClient(plr)
game.ReplicatedStorage.TakedownAnimV1:FireClient(plr)
script.Parent.Parent.Humanoid.Health = 10
else
print("Takedown is not available at the moment")
end
wait(1)
db = true
end
end)
It seems like you’ll have to assign the HumanoidRootPart’s CFrame to where the Target is currently facing, try this:
local hitbox = script.Parent
local knife = game.StarterPack:FindFirstChild("Knife")
local db = true
hitbox.Touched:Connect(function(hit)
local char = hit.Parent
local hum = char and char:FindFirstChild("Humanoid")
local plr = game.Players:FindFirstChild(char.Name)
if db and hum and plr then
db = false
char.HumanoidRootPart.CFrame = CFrame.new(char.HumanoidRootPart.Position, Target.Position)
local KTF = plr:WaitForChild("KTF")
local KT = KTF:FindFirstChild("Takedown")
if KT.Value then
KT.Value = false
game.ReplicatedStorage.TakedownCam:FireClient(plr)
game.ReplicatedStorage.TakedownAnimV1:FireClient(plr)
script.Parent.Parent.Humanoid.Health = 10
else
print("Takedown is not available at the moment")
end
wait(1)
db = true
end
end)
You’ll have to reference where the Target is though
You could just reference the Hitbox’s Position as this then I’d assume
local hitbox = script.Parent
local knife = game.StarterPack:FindFirstChild("Knife")
local db = true
hitbox.Touched:Connect(function(hit)
local char = hit.Parent
local hum = char and char:FindFirstChild("Humanoid")
local plr = game.Players:FindFirstChild(char.Name)
if db and hum and plr then
db = false
char.HumanoidRootPart.CFrame = CFrame.new(char.HumanoidRootPart.Position, hitbox.Position)
local KTF = plr:WaitForChild("KTF")
local KT = KTF:FindFirstChild("Takedown")
if KT.Value then
KT.Value = false
game.ReplicatedStorage.TakedownCam:FireClient(plr)
game.ReplicatedStorage.TakedownAnimV1:FireClient(plr)
script.Parent.Parent.Humanoid.Health = 10
else
print("Takedown is not available at the moment")
end
wait(1)
db = true
end
end)