I'm trying to make my script wait until the character loads. I attempted to do..
game.Players.PlayerAdded:wait() --and.. game.Players.ChildAdded:wait()
..but neither of the functions fired. Probably fired before the character joined the game.
--In "ReplicatedFirst" local Player = game.Players.??? local PlayerGui = Player.WaitForChild('PlayerGui') local ScreenGui = PlayerGui:WaitForChild('ScreenGui') local Loading = Instance.new('TextLabel',ScreenGui) Loading.Text = 'Loading...' Loading.BackgroundTransparency = 0.5 Loading.BackgroundColor = BrickColor.new(0,0,0) Loading.Size = UDim2.new(1,0,1,0) Loading.Font = 'SciFi' Loading.Name = 'Loading'
Is there any other way to get the player name so I can just do game.Players:WaitForChild(LocalPlayer)?
You would get the player name by doing this
local player = game.Players.LocalPlayer local player_name = player.Name
This only works in LocalScripts!
Also, you used
Gui.BackgroundColor = BrickColor.new()
That's wrong, you would need to use a Color3
Gui.BackgroundColor = Color3.new(0, 0, 0)
I saw you wanted it to be black, so i did that already
The final code
local Player = game.Players.LocalPlayer player.CharacterAdded:wait() -- Waiting for the character to spawn! :D local PlayerGui = Player.WaitForChild('PlayerGui') local ScreenGui = PlayerGui:WaitForChild('ScreenGui') local Loading = Instance.new('TextLabel',ScreenGui) Loading.Text = 'Loading...' Loading.BackgroundTransparency = 0.5 Loading.BackgroundColor = Color3.new(0, 0, 0) Loading.Size = UDim2.new(1,0,1,0) Loading.Font = 'SciFi' Loading.Name = 'Loading'
Hope i helped!
~jordikeijzers