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

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

Asked by 7 years ago
Edited by OldPalHappy 7 years ago

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)
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 OldPalHappy 1477 — 7y

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

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.

Ad

Answer this question