mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 15:10:03 +00:00
35 lines
927 B
Lua
35 lines
927 B
Lua
--!strict
|
|
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.new(class)
|
|
newInstance.Name = name
|
|
newInstance.Parent = parent
|
|
end
|
|
end
|
|
|
|
local function waitForChildren(parent: Instance, childrenNames: {string})
|
|
for _, name in ipairs(childrenNames) do
|
|
task.spawn(function()
|
|
repeat
|
|
task.wait()
|
|
until parent:FindFirstChild(name)
|
|
end)
|
|
end
|
|
end
|
|
|
|
if RunService:IsServer() then
|
|
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
|