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

Why won't the GUI load when the player spawns?

The purpose of this script is to load a GUI when a player on the 'soldier' team spawns.

Please tell me where I went wrong,

Respectfully, M


local ui = game.ReplicatedStorage.Gui2 --This is the gui to be cloned

game.Players.CharacterAdded:connect(function(plr)
	if (plr.TeamColor == game.Teams["soldier"].TeamColor) then
    local plrui = plr:WaitForChild("PlayerGui");
    ui:Clone().Parent = plrui;
	end
end)

1 comment

0

I edited your question for a codeblock. Please do this yourself in the future: https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site

1 answer

I believe you meant to use PlayerAdded, not CharacterAdded; the latter is a member of Player, not the Players service.

local ui = game.ReplicatedStorage.Gui2 --This is the gui to be cloned

game.Players.PlayerAdded:connect(function(plr)
    if (plr.TeamColor == game.Teams["soldier"].TeamColor) then 
        local plrui = plr:WaitForChild("PlayerGui");
        ui:Clone().Parent = plrui;
    end
end)

Either way, you should do GUI-related stuff on the client (that is, in a LocalScript). Read more on that here.

Hope this helped.

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