Coroutine doesn't do wait?
For some reason this code does not work for me, I never see "DONE" in the output, nor does it say it's not running. How can I fix this?
1 | coroutine.resume(coroutine.create( function () |
2 | print (coroutine.running()) |
Full Script:
007 | _G.Defaults = { [ "WalkSpeed" ] = 16 , [ "MaxHealth" ] = 200 , [ "Armor" ] = 0 } |
011 | _G.TakeDamage = function (name, damage) |
012 | player = game.Players:findFirstChild(player) |
014 | if (player.Character) then |
015 | noid = player.Character.Humanoid |
016 | noid.Health = noid.Health - damage |
021 | _G.addEffect = function (name, stat, increase, duration) |
022 | player = game.Players:findFirstChild(name) |
024 | if (stat = = "WalkSpeed" ) then |
025 | noid = player.Character.Humanoid |
026 | if (noid.WalkSpeed < _G.MaxWalkSpeed) then |
027 | value = noid.WalkSpeed + increase |
028 | if (value > _G.MaxWalkSpeed) then |
029 | value = value - (value - _G.MaxWalkSpeed) |
031 | table.insert(database, { name, stat, noid.WalkSpeed } ) |
032 | noid.WalkSpeed = value |
033 | print (( "Effects: Set %s's WalkSpeed to %s." ):format(name, value)) |
035 | print (( "Effects: Reached maximum walkspeed on %s." ):format(name)) |
038 | elseif (stat = = "Armor" ) then |
039 | armor = player.Backpack:findFirstChild( "Armor" ) |
041 | value = armor.Absorbance.Value + increase |
042 | if (armor.Absorbance.Value < _G.MaxArmor) then |
043 | if (value > _G.MaxArmor) then |
044 | value = value - (value - _G.MaxArmor) |
046 | table.insert(database, { name, stat, armor.Absorbance.Value } ) |
047 | armor.Absorbance.Value = value |
048 | armor.Health.Value = 250 |
050 | print (( "Effects: %s has reached maximum armor." ):format(name)) |
053 | elseif (stat = = "MaxHealth" ) then |
054 | noid = player.Character.Humanoid |
055 | if (noid.MaxHealth < _G.MaxHealth) then |
056 | value = noid.MaxHealth + increase |
057 | if (value > _G.MaxHealth) then |
058 | value = value - (value - _G.MaxHealth) |
060 | table.insert(database, { name, stat, noid.MaxHealth } ) |
061 | noid.WalkSpeed = value |
062 | print (( "Effects: Set %s's MaxHealth to %s." ):format(name, value)) |
064 | print (( "Effects: Reached maximum health on %s." ):format(name)) |
068 | if (duration > 0 ) then |
069 | addEffectTimer(name, stat, duration) |
074 | function hasPrevious(name, stat) |
075 | for index = 1 , #database do |
077 | if (entry [ 1 ] = = name) then |
078 | if (entry [ 2 ] = = stat) then |
086 | function addEffectTimer(name, stat, duration) |
087 | coroutine.resume(coroutine.create( function () |
088 | print (coroutine.running()) |