Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
|
| 19 Jul 2013 05:09 PM |
| My global functions seemed to have stopped working. They're really old and the script hasn't been updated in a long time. What is the current/best method? |
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 19 Jul 2013 05:10 PM |
_G.NewFunction = (function() --blah end)
-- There are many methods, but I use this. |
|
|
| Report Abuse |
|
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
| |
|
|
| 19 Jul 2013 05:16 PM |
function name()
end
_G.FuncName = coroutine.wrap(name)
Much better version because it wraps it into a coroutine... and I like coroutines because they will not break a script if it errors... |
|
|
| Report Abuse |
|
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
|
| 19 Jul 2013 05:19 PM |
Thanks, but now I have a new problem. No matter what I do, I cannot seem to get the script to remove a model. Here's the general concept:
_G.destroy = (function(model, name) model:destroy() end)
Not sure if the ROBLOX Engine is limiting this or what, but it only works 1/10 times. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 05:24 PM |
_G.destroy = coroutine.wrap(function(model,name) model:Destroy() delay(0.1,function() if model and model.Parent then game:service('Debris'):AddItem(model,0) end end) end)
This is one way to make it inside a coroutin [better!] aswell as it has a fallback incase Destroy doesn't work... |
|
|
| Report Abuse |
|
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
|
| 19 Jul 2013 05:32 PM |
| Okay Christbru, I'll do it your way. Lol |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 05:47 PM |
Lol, Alrighty cx Main reason why I recommend using coroutine.wrap is because with a coroutine you can call it multiple times and they'll all run along side eachother, where as with usual functions you have to wait until the function is done before trying to use it again... aswell as with a coroutine if there is an error inside of the coroutine it will break itself, not the script, and better yet it can be called again without a problem [unless the error stops it again] |
|
|
| Report Abuse |
|
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
|
| 19 Jul 2013 05:53 PM |
"Multiple times"
17:36:50.772 - Workspace.Weapon.DamageScript:45: cannot resume dead coroutine 17:36:50.773 - Script "Workspace.Weapon.DamageScript", Line 45 17:36:50.774 - stack end |
|
|
| Report Abuse |
|
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
| |
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
| |
|
Xtreme101
|
  |
| Joined: 03 Jan 2009 |
| Total Posts: 4385 |
|
| |
|