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

My gui doesn't clone in the player gui when loading into the game. What's going on with my code?

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?

function onPlayerEnter()
	local gui = script.Parent.Gui.LoadingGui
	local playergui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
	gui:Clone().Parent = playergui
end
game.Players.PlayerAdded:Connect(onPlayerEnter)

5 comments

0

Server script or LocalScript?

0

playeradded maybe?

0

That's what they are using.

0

So basically the script gives the new player the loading gui? You can just place the gui inside StarterGui and set ResetOnSpawn to false

0

^^ Didn't even think of that for some reason.

3 answers

✓ Accepted answer

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.

function onPlayerEnter(player)
    local gui = script.Parent.Gui.LoadingGui
    local playergui = player:WaitForChild("PlayerGui")
    gui:Clone().Parent = playergui
end
game.Players.PlayerAdded:Connect(onPlayerEnter)

2 comments

0

This is incorrect since playergui cannot be accessed through the server.

0

I've been placing stuff into the PlayerGui using the server for two years, haven't had any issues at all. I do all the manipulating of the GUI on the client though.

Try function onPlayerEntered() or convert it to a ServerScript.

2 comments

0

The name of the function does not matter.

1

What he should do, is add an argument to the function called "player" or "plr" or whatever and use that instead of LocalPlayer.

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