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.
01 | while wait() do |
02 | local plr = game.Players:GetPlayerFromCharacter() |
03 | if plr.TeamColor = = BrickColor.new( "Really red" ) then |
04 | local gui = game.ReplicatedStorage.HostUI |
05 | gui.Parent = game.Players.LocalPlayer.PlayerGui |
06 | wait( 1 ) |
07 | gui.HostFrame.Visible = true |
08 | local k = game.ReplicatedStorage.kill:Clone() |
09 | wait() |
10 | k.Parent = plr.Backpack |
11 | end |
12 | end |
Any problems with this script?
Hello, OldBo5!
Try this script:
01 | game.Players.PlayerAdded:Connect( function () |
02 | for i,plr in pairs (game.Players:GetChildren()) do |
03 | if plr.TeamColor = = BrickColor.new( "Really red" ) then |
04 | print (plr.Name .. " is on Really Red Team!" ) |
05 | local gui = game.ReplicatedStorage.HostUI |
06 | gui.HostFrame.Visible = true |
07 | game.ReplicatedStorage.kill:Clone().Parent = plr.Backpack |
08 | end |
09 | end |
10 | end ) |
ATTENTION: This script will work until player leaves the team!
Good Luck with your games!
01 | local plr = game:GetService( "Players" ).LocalPlayer --Define my player |
02 |
03 | repeat |
04 | plr:GetPropertyChangedSignal( "Team" ):wait() |
05 | until plr.Team.Name = = "Host" --Everytime the Team property changes, check if it's host, if it is then stop waiting |
06 | local gui = game.ReplicatedStorage.HostUI:Clone() --Make a clone of the gui |
07 | gui.Parent = plr.PlayerGui -- Put the gui inside of the PlayerGui |
08 | wait( 1 ) |
09 | gui.HostFrame.Visible = true |
10 | local k = game.ReplicatedStorage.kill:Clone() |
11 | wait() |
12 | k.Parent = plr.Backpack |