Zecrit
|
  |
| Joined: 24 Jan 2013 |
| Total Posts: 2618 |
|
|
| 13 Oct 2013 08:46 AM |
I need to turn some scripts that should be used independently into globals to reduce overall lag.
Turn this into a global so I can see how it's done and I'll be fine from there:
-------------------
tool = game.Lighting: FindFirstChild(script.Parent.Tool.Value)
function onChildAdded(part) local A = part.Part1.Parent local B = game.Players:GetPlayerFromCharacter(A) if (B.TeamColor == script.Parent.Parent.Parent.TeamColor.Value) then local C = script.Parent.ModelTag:clone() C.Value = script.Parent.Parent C.Parent = A local Tool = tool:clone() Tool.Parent = B.Backpack Tool.Ship.Value = script.Parent.Parent.Parent Tool.TextureId = script.Parent.Parent.Parent.DataTable.ToolTexture.Value local TG = Tool.TargetGui TG.Parent = B.PlayerGui else A.Humanoid:TakeDamage(110) end end
function onChildRemoved(part) local A = part.Part1.Parent local B = game.Players:GetPlayerFromCharacter(A) if (A:FindFirstChild("ModelTag")) then A.ModelTag:remove() end local Tool = B.Backpack:FindFirstChild(script.Parent.Tool.Value) if (Tool ~= nil) then Tool: remove() end local TG = B.PlayerGui:FindFirstChild("TargetGui") if (TG ~= nil) then TG:remove() end end
script.Parent.ChildAdded:connect(onChildAdded) script.Parent.ChildRemoved:connect(onChildRemoved) -------------------
It's an average toolgiver when you sit on a seat, but it's independent so it's in every seat I need it to be but I'd like to turn this into a global. And I do know it'll probably require some brick-within-model maneuvering |
|
|
| Report Abuse |
|
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 13 Oct 2013 09:09 AM |
What do yo mean by global?
If you are referring to global variables, just no... local variables are faster than global variables. |
|
|
| Report Abuse |
|
|
Zecrit
|
  |
| Joined: 24 Jan 2013 |
| Total Posts: 2618 |
|
| |
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 13 Oct 2013 09:16 AM |
_G["TestFunction"] = function() code code code end
to call:
_G.TestFunction() |
|
|
| Report Abuse |
|
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 13 Oct 2013 09:27 AM |
| That would not reduce lag, just decrease file size. It may even increase the lag because Indexing. |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 13 Oct 2013 09:33 AM |
| Global functions aren't as efficient as people think. They are just useful in some ways. |
|
|
| Report Abuse |
|
|