#WHY DOES IT LAG when i destroy a model
1 messages · Page 1 of 1 (latest)
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)
destroying a script is known for causing a lag spike
is there any way to get around this?
have a main script that loops through a folder with all the model are in and then apply the touch connection there