mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 15:10:03 +00:00
Update Event.luau
Readability improvements.
This commit is contained in:
parent
0fb349fe0f
commit
7e06d676bf
1 changed files with 24 additions and 12 deletions
|
@ -2,18 +2,30 @@
|
||||||
local RunService = game:GetService("RunService")
|
local RunService = game:GetService("RunService")
|
||||||
local Type = require(script.Parent.Type)
|
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
|
||||||
|
task.spawn(function()
|
||||||
|
repeat
|
||||||
|
task.wait()
|
||||||
|
until parent:FindFirstChild(name)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if RunService:IsServer() then
|
if RunService:IsServer() then
|
||||||
if not script:FindFirstChild("Reliable") then
|
createInstance(script, "Reliable", "RemoteEvent")
|
||||||
Instance.new("RemoteEvent", script).Name = "Reliable"
|
createInstance(script, "Unreliable", "UnreliableRemoteEvent")
|
||||||
end
|
createInstance(script, "Request", "RemoteEvent")
|
||||||
if not script:FindFirstChild("Unreliable") then
|
else
|
||||||
Instance.new("UnreliableRemoteEvent", script).Name = "Unreliable"
|
waitForChildren(script, {"Reliable", "Unreliable", "Request"})
|
||||||
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")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue