#How can i make this More optimized / efficient?

1 messages · Page 1 of 1 (latest)

tacit drift
#

I feel like i could make it more efficient / accurate and not just this basic lump of code

    
    Hitbox.Touched:Connect(function(hit)
        local Character = hit.Parent
        local Humanoid = Character:WaitForChild("Humanoid")
        
        if Humanoid and Character.Name ~= plr.Name then
            if not HasTakenDamage then
                HasTakenDamage = true
                local sound = script.hit_punch_l:Clone()
                sound.Parent = Humanoid
                task.wait(0.1)
                sound:Play()
                game.Debris:AddItem(sound, 2)
                
                local bh = game.ReplicatedStorage["Basic hit"].Attachment:Clone()
                bh.Parent = Character:FindFirstChild("HumanoidRootPart")
                for _, v in pairs(bh:GetChildren()) do
                    if v:IsA("ParticleEmitter") then
                        v:Emit(v:GetAttribute("EmitCount"))
                    end
                end
                
                game.Debris:AddItem(bh, 0.2)
                
                Humanoid:TakeDamage(5)
                local Knockback = Character.Humanoid
                task.wait(5)
                HasTakenDamage = false
            end
        end
    end)
end)
#

I feel like i could make it more efficient / accurate and not just this basic lump of code

spiral smelt
#

i'd suggest using guard clauses, but that has nothing to do with efficiency or accuracy or optimization.

tacit drift
#

but i wonder how i can make a magnitude hitobox instead

spiral smelt
tacit drift
#

But i heard that Magnitude doesnt work well

tacit drift
#

I used to think combat systems were only for Hella good scripters

spiral smelt
tacit drift
#

lag compensation

#

If someone on 460 ms hits someone on 30 ms wouldnt it still be the same

spiral smelt
tacit drift
#

Alr, thanks

#

Have a good day