This commit is contained in:
Bl4ise 2024-05-02 12:03:31 +02:00 committed by GitHub
commit f587dca982
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,18 +2,28 @@
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
repeat
task.wait()
until parent:FindFirstChild(name)
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 {