mirror of
				https://github.com/imezx/Warp.git
				synced 2025-11-03 19:49:16 +00:00 
			
		
		
		
	Update Event.luau
Let's make this easier to read!
This commit is contained in:
		
							parent
							
								
									0fb349fe0f
								
							
						
					
					
						commit
						6e695d9546
					
				
					 1 changed files with 22 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -2,22 +2,32 @@
 | 
			
		|||
local RunService = game:GetService("RunService")
 | 
			
		||||
local Type = require(script.Parent.Type)
 | 
			
		||||
 | 
			
		||||
local function createInstance(parent: Instance, name: string, class: string)
 | 
			
		||||
	if not parent:FindFirstChild(name) then
 | 
			
		||||
		local newInstance: Instance = Instance.new(class)
 | 
			
		||||
		newInstance.Name = name
 | 
			
		||||
		newInstance.Parent = parent
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function waitForChildren(parent: Instance, childrenNames: {string})
 | 
			
		||||
	for _, name: string in ipairs(childrenNames) do
 | 
			
		||||
		repeat
 | 
			
		||||
			task.wait()
 | 
			
		||||
		until parent:FindFirstChild(name)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
if RunService:IsServer() then
 | 
			
		||||
	if not script:FindFirstChild("Reliable") then
 | 
			
		||||
		Instance.new("RemoteEvent", script).Name = "Reliable"
 | 
			
		||||
	end
 | 
			
		||||
	if not script:FindFirstChild("Unreliable") then
 | 
			
		||||
		Instance.new("UnreliableRemoteEvent", script).Name = "Unreliable"
 | 
			
		||||
	end
 | 
			
		||||
	if not script:FindFirstChild("Request") then
 | 
			
		||||
		Instance.new("RemoteEvent", script).Name = "Request"
 | 
			
		||||
	end
 | 
			
		||||
elseif not script:FindFirstChild("Reliable") or not script:FindFirstChild("Unreliable") or not script:FindFirstChild("Request") then
 | 
			
		||||
	repeat task.wait() until script:FindFirstChild("Reliable") and script:FindFirstChild("Unreliable") and script:FindFirstChild("Request")
 | 
			
		||||
	createInstance(script, "Reliable", "RemoteEvent")
 | 
			
		||||
	createInstance(script, "Unreliable", "UnreliableRemoteEvent")
 | 
			
		||||
	createInstance(script, "Request", "RemoteEvent")
 | 
			
		||||
else
 | 
			
		||||
	waitForChildren(script, {"Reliable", "Unreliable", "Request"})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
	Reliable = script.Reliable,
 | 
			
		||||
	Unreliable = script.Unreliable,
 | 
			
		||||
	Request = script.Request
 | 
			
		||||
} :: Type.Event
 | 
			
		||||
} :: Type.Event
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue