Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help me It says attempt with index nil with 'Loading'?

This is a localscript in replicatedFirst.

Error:

ReplicatedFirst.CoreScript:4: attempt to index nil with 'Loading'

Script:

local player = game.Players.LocalPlayer
local LoadGui = player.PlayerGui:FindFirstChild('LoadingGUI')

LoadGui.Loading.Position = UDim2.new(0.5, 0, 0.5, 0)

repeat wait() until player:IsDescendantOf(workspace)

if player:IsDescendantOf(workspace) then
	LoadGui:TweenPosition(UDim2.new(10, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5)
end

I'm confused.

2 answers

Line 4 is where the error is.

local player = game.Players.LocalPlayer
local LoadGui = player.PlayerGui:FindFirstChild('LoadingGUI')

LoadGui.Loading.Position = UDim2.new(0.5, 0, 0.5, 0)  -- This Is The Error

repeat wait() until player:IsDescendantOf(workspace)

if player:IsDescendantOf(workspace) then
	LoadGui:TweenPosition(UDim2.new(10, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5)
end

Here is the solution. You need to wait for the asset to load in! I have also removed the default loading screen for you.

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

local player = game.Players.LocalPlayer
local LoadGui = player.PlayerGui:WaitForChild('LoadingGUI')

LoadGui:WaitForChild("Loading").Position = UDim2.new(0.5, 0, 0.5, 0)

game.Loaded:Wait()

LoadGui:TweenPosition(UDim2.new(10, 0, 0.5, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5)

5 comments

0

Your answer didn't work, it made me have Errors! "Attempt to call index nil with 'WaitForChild'. "

0

WAIT NO I PUT THE GUI IN STARTER GUI, IM SO DUMB LOL

0

Just add math.huge to the prams in waitforchild sorry!

0

idk what prams is

0

add a comma to waiterchild then put math.huge

This discussion is preserved as it was. New answers, comments, and votes are closed.