#WHY DOES IT LAG when i destroy a model

1 messages · Page 1 of 1 (latest)

unreal vale
#

im making a health item and it lags alot when i collect it this is a simple model with ~5 lowpolly meshparts in it and just this script.(SCRIPT IS IN COMMENTS)

#
local model = part.Parent
local healAmount = 50
local used = false

part.Touched:Connect(function(hit)
    if used then return end
    local character = hit.Parent
    local humanoid = character and character:FindFirstChildWhichIsA("Humanoid")
    if humanoid and humanoid.Health > 0 then
        used = true
        humanoid.Health = math.min(humanoid.Health + healAmount, humanoid.MaxHealth)
        task.defer(function()
            model:Destroy()
        end)
    end
end)
signal wharf
unreal vale
fickle crag
signal wharf