so my hitboxes sometimes works and sometimes dosnt im also using getpartsinpart on the client.
client
UserInputService.InputBegan:Connect(function(input) if Equipped == true then if input.UserInputType == Enum.UserInputType.MouseButton1 then if AnimPlaying == false and HitOrder < 5 then local HitboxCoroutine = coroutine.wrap(function(Character) wait(0.06) local Clone = Hitbox:Clone() local Weld = Instance.new("WeldConstraint") local TouchingParts = workspace:GetPartsInPart(Clone) for i,v in pairs(TouchingParts) do if v:IsA("Part") then if v.Parent.Name ~= player.Name and v.Name == "Hitbox" then print(v) CombatM1:FireServer(HitOrder,v) end end end Clone.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-1.5) Weld.Part0 = player.Character.HumanoidRootPart Weld.Part1 = Clone Clone.Parent = player.Character Weld.Parent = Clone wait(0.05) Clone:Destroy() end) HitOrder += 1 local CurrentAnim = AnimTracks["Hit" .. HitOrder] HitboxCoroutine(Character) CombatTimer:Reset() CombatTimer:Start() AnimPlaying = true CurrentAnim:Play(0.1,1,1.1) Swing:Play() CurrentAnim.Stopped:Wait(0.4) AnimPlaying = false if HitOrder >= 5 then wait(1.3) CombatTimer:Reset() HitOrder = 0 end CombatTimer.Completed:Connect(function(count) CombatTimer:Reset() HitOrder = 0 end) end end end end)
server
CombatM1.OnServerEvent:Connect(function(player,HitOrder,Target) -- target = humanoidrootpart local DotProduct = player.Character.HumanoidRootPart.CFrame.LookVector:Dot((Target.Position - player.Character.HumanoidRootPart.Position).Unit) local Distance = (player.Character.HumanoidRootPart.Position - Target.Position).Magnitude local Damage = player.PlayerStats.Damage local RandomNumber = math.random(1,3) local OnHitAnimTrack = Target.Parent.Humanoid:LoadAnimation(OnHitAnims[RandomNumber]) if DotProduct > 0.2 then if Distance <= 4.5 then local KnockBack = Instance.new("BodyVelocity") KnockBack.MaxForce = Vector3.new(500000,500000,500000) Target.Parent.Humanoid.Health -= Damage.Value OnHitEvent:FireClient(player) OnHitAnimTrack:Play() if HitOrder < 5 then KnockBack.Parent = Target KnockBack.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * Vector3.new(0,0,10) wait(0.15) KnockBack:Destroy() elseif HitOrder >= 5 then KnockBack.Parent = Target KnockBack.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * Vector3.new(0,0,50) wait(0.3) KnockBack:Destroy() end end end end)
https://gyazo.com/2ea63de4937053919120e0c5d7696c43