Working on a punching system but I don’t wanna use a hitbox touched event so instead, I’m using magnitude and player FOV. I came across this, however, it isn’t working for me. Here is my script.
local db = false
local combo = 0
local event = script.Parent:WaitForChild("Punch")
local c = script.Parent.Parent
event.OnServerEvent:Connect(function()
if db then return end
if c.Humanoid.Health <= 0 then return end
if c.Stunned.Value == true or c.IFrame.Value == true or c.AbilityBeingCast.Value == true then return end --this is just some checkups on the player, don't worry about this
if combo == 0 then
print("combo 0")
for i, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
if v ~= c then
print("humanoid found")
local hrp = c.HumanoidRootPart
local enemyHRP = v.HumanoidRootPart
local enemyHum = v.Humanoid
local magn = (hrp.Position - enemyHRP.Position).magnitude
local radius = 5
local angle = 45
if magn <= radius then
print("in radius")
local dot = hrp.Position:Dot(enemyHRP.Position)
print("dot") --prints this and every print() up to this
if dot >= 0 and dot <= math.cos(math.rad(angle)) then
print("humanoid in range") --never reaches this??
end
end
end
end
end
end
end)