When using GetDescendants or GetChildren to make a loading screen, scripts load, but don't work. Is there a similar method to use which makes scripts work inside Parts, MeshParts, etc?
Here's my code, to check if I'm doing something wrong:
local Players = game:GetService("Players") local ContentProvider = game:GetService("ContentProvider") local TweenService = game:GetService("TweenService") local ReplicatedFirst = game:GetService("ReplicatedFirst") local PlayerGUI = Players.LocalPlayer.PlayerGui local loadingScreen = script.ScreenGui loadingScreen.DisplayOrder = 20 loadingScreen.Parent = PlayerGUI local Lobby = game.ReplicatedStorage:WaitForChild("Lobby") local toLoad = Lobby:GetDescendants() local loadingRing = Instance.new("ImageLabel") loadingRing.Size = UDim2.new(0, 256, 0, 256) loadingRing.BackgroundTransparency = 1 loadingRing.Image = "rbxassetid://4965945816" loadingRing.AnchorPoint = Vector2.new(0.5, 0.5) loadingRing.Position = UDim2.new(0.5, 0, 0.5, 0) loadingRing.Parent = loadingScreen.Background local counter = Instance.new("TextLabel") counter.Font = Enum.Font.Gotham counter.Position = UDim2.new(0.5, 0, 0.75, 0) counter.BackgroundTransparency = 1 counter.TextColor3 = Color3.fromRGB(246, 246, 246) counter.AnchorPoint = Vector2.new(0.5, 0.75) counter.TextSize = 45 counter.Parent = loadingScreen.Background local total = #toLoad local tweenInfo = TweenInfo.new(4, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1) local tween = TweenService:Create(loadingRing, tweenInfo, {Rotation = 360}) ReplicatedFirst:RemoveDefaultLoadingScreen() for i, v in pairs(toLoad) do counter.Text = "Loading: " .. i .. "/" .. total .. " " .. v.Name tween:Play() ContentProvider:PreloadAsync({v}) end Lobby.Parent = game.Workspace wait(8) loadingScreen:Destroy()
Have a great day and happy Pride Month! (Sorry if my English is not that good; I'm not a native speaker and I'm still learning)