What do you want to achieve? For the instance to wait 15 seconds before being destroyed
What is the issue? instance is not destroying after 15 seconds
What solutions have you tried so far? I tested setting the wait to 1 seconds and behold it worked, all instances that lost health at once were destroyed a second later however I need it to be 15 seconds. I have tried coroutines but that doesn’t change things.
local HealthHandler = {}
function HealthHandler.healthDeduction(health, instance)
instance.Health.Value = health
coroutine.wrap(function()
if instance.Health.Value <= 0 then
instance.Anchored = false
instance.Material = Enum.Material.CorrodedMetal
print("got to this point")
wait(15)
instance:Destroy()
print("Destroyed " .. instance.Name)
elseif instance.Health.Value ~= 150 then
instance.Material = Enum.Material.CorrodedMetal
print("not destroyed")
end
end)()
end
return HealthHandler
when I do this it will only destroy 1 instance at a time rather than before when it affects all instances (makes them be corroded) but doesnt destroy them
yes, i am calling it from a seperate module script which has a function that needs this “healthDeduction” function, the module script is being used by a server script so I don’t see why this isn’t working
no, it just seems like none of the instances are waiting 15 seconds to be destroyed, which causes a lot of performance issues since a bunch of parts are being unanchored and are staying in the workspace