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)
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.