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

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

Asked by 6 years ago

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)
0
Server script or LocalScript? lunatic5 409 — 6y
0
playeradded maybe? DuckMaster11211 13 — 6y
0
That's what they are using. lunatic5 409 — 6y
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 hellmatic 1523 — 6y
0
^^ Didn't even think of that for some reason. lunatic5 409 — 6y

3 answers

Log in to vote
1
Answered by 6 years ago

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.

Ad
Log in to vote
1
Answered by
gitrog 326 Moderation Voter
6 years ago

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)
0
This is incorrect since playergui cannot be accessed through the server. poke7667 142 — 6y
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. gitrog 326 — 6y
Log in to vote
-2
Answered by 6 years ago

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

0
The name of the function does not matter. lunatic5 409 — 6y
1
What he should do, is add an argument to the function called "player" or "plr" or whatever and use that instead of LocalPlayer. lunatic5 409 — 6y

Answer this question