The title explains it all. I can't figure out why the loading screen doesn't load into the player's gui when loading into the game. Can someone help?
1 | function onPlayerEnter() |
2 | local gui = script.Parent.Gui.LoadingGui |
3 | local playergui = game.Players.LocalPlayer:WaitForChild( "PlayerGui" ) |
4 | gui:Clone().Parent = playergui |
5 | end |
6 | game.Players.PlayerAdded:Connect(onPlayerEnter) |
The server shouldn't be manipulating the PlayerGui. Use a RemoteEvent to do so and a LocalScript to show or clone the gui.
The Client shouldn't be checking for a player to join either. Instead use a RemoteEvent for this.
Either solution should solve your issue.
What it looks like you're doing is trying to call LocalPlayer through what looks like a server script. What you should do is use the "Player" argument of the PlayerAdded function.
1 | function onPlayerEnter(player) |
2 | local gui = script.Parent.Gui.LoadingGui |
3 | local playergui = player:WaitForChild( "PlayerGui" ) |
4 | gui:Clone().Parent = playergui |
5 | end |
6 | game.Players.PlayerAdded:Connect(onPlayerEnter) |
Try function onPlayerEntered() or convert it to a ServerScript.