Ad
Log in to vote
1

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

Asked by 5 days ago
Edited 5 days 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 5 days 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
DJhar09 90
5 days 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 19 — 5d
0
WAIT NO I PUT THE GUI IN STARTER GUI, IM SO DUMB LOL poppyloverb 19 — 5d
0
Just add math.huge to the prams in waitforchild sorry! DJhar09 90 — 4d

Answer this question