Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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
Ad
Log in to vote
0
Answered by 3 years ago

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)
0
Your answer didn't work, it made me have Errors! "Attempt to call index nil with 'WaitForChild'. " poppyloverb 20 — 3y
0
WAIT NO I PUT THE GUI IN STARTER GUI, IM SO DUMB LOL poppyloverb 20 — 3y
0
Just add math.huge to the prams in waitforchild sorry! User#39832 0 — 3y
0
idk what prams is poppyloverb 20 — 3y
0
add a comma to waiterchild then put math.huge User#39832 0 — 3y

Answer this question