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

GUI and backpack won't show when players team is changed?

So, when a player is on the "Host" team or becomes a host, I want the player to have a GUI pop up as soon as that happens.

while wait() do
local plr = game.Players:GetPlayerFromCharacter()
    if plr.TeamColor == BrickColor.new("Really red") then
        local gui = game.ReplicatedStorage.HostUI
        gui.Parent = game.Players.LocalPlayer.PlayerGui
		wait(1)
		gui.HostFrame.Visible = true
		local k = game.ReplicatedStorage.kill:Clone()
		wait()
		k.Parent = plr.Backpack
end
end

Any problems with this script?

2 answers

Hello, OldBo5!

Try this script:

game.Players.PlayerAdded:Connect(function()
	for i,plr in pairs(game.Players:GetChildren()) do
		if plr.TeamColor == BrickColor.new("Really red") then
			print(plr.Name .. " is on Really Red Team!")
			local gui = game.ReplicatedStorage.HostUI
			gui.HostFrame.Visible = true
			game.ReplicatedStorage.kill:Clone().Parent = plr.Backpack
		end
	end
end)

ATTENTION: This script will work until player leaves the team!

Good Luck with your games!

local plr = game:GetService("Players").LocalPlayer --Define my player

repeat 
	plr:GetPropertyChangedSignal("Team"):wait() 
until plr.Team.Name == "Host" --Everytime the Team property changes, check if it's host, if it is then stop waiting
local gui = game.ReplicatedStorage.HostUI:Clone() --Make a clone of the gui
gui.Parent = plr.PlayerGui -- Put the gui inside of the PlayerGui
wait(1)
gui.HostFrame.Visible = true
local k = game.ReplicatedStorage.kill:Clone()
wait()
k.Parent = plr.Backpack

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