I have 2 characters, one which is controlled by the player and one dummy
if the player clicks, a punching animation appears
problem is I can’t get a raycast to work properly, I want it to check for any target within 5 studs infront of my torso and if it finds any, to deal damage
local Character = Fist.Parent
local Torso = Character:FindFirstChild("Torso")
if Torso then
local RaycastResult = workspace:Raycast(Torso.Position, Vector3.new(Torso.CFrame.LookVector.X, 0, Torso.CFrame.LookVector.Z+5))
if RaycastResult then
print("Instance:", RaycastResult.Instance)
print("Position:", RaycastResult.Position)
print("Distance:", RaycastResult.Distance)
else
warn("No raycast result!")
end
if RaycastResult and RaycastResult.Instance and RaycastResult.Instance:IsA("Model") then
local TargetHumanoid = RaycastResult.Instance:FindFirstChildOfClass("Humanoid")
print("found")
TargetHumanoid:TakeDamage(10)
end
end