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

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

Asked by
OldBo5 30
7 years ago
Edited 7 years ago

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.

01while wait() do
02local 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
11end
12end

Any problems with this script?

2 answers

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

Hello, OldBo5!

Try this script:

01game.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
10end)

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

Good Luck with your games!

Ad
Log in to vote
0
Answered by 7 years ago
01local plr = game:GetService("Players").LocalPlayer --Define my player
02 
03repeat
04    plr:GetPropertyChangedSignal("Team"):wait()
05until plr.Team.Name == "Host" --Everytime the Team property changes, check if it's host, if it is then stop waiting
06local gui = game.ReplicatedStorage.HostUI:Clone() --Make a clone of the gui
07gui.Parent = plr.PlayerGui -- Put the gui inside of the PlayerGui
08wait(1)
09gui.HostFrame.Visible = true
10local k = game.ReplicatedStorage.kill:Clone()
11wait()
12k.Parent = plr.Backpack

Answer this question