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

How do I get a part of this script to re run after someone joins a team?

Asked by 6 years ago
local rankTbl = {
    -- format userid  = rank 
    [26331361] = "Overseer",
    [26332121] = "O5-2",
    [117372267] = "Site Director",
    [84185807] = "O5-X",
    [311774526] = "Class-D",
    [473500261] = "Level-1"
}
    local SD = BrickColor.new("Medium stone grey")
    local ET = BrickColor.new("Cool yellow")
    local MD = BrickColor.new("Bright bluish green")
    local CD = BrickColor.new("Bright orange")
    local FP = BrickColor.new("White")
    local CI = BrickColor.new("Really black")
    local CE = BrickColor.new("Black")
    local DEA = BrickColor.new("Pastel light blue")
    local DoR = BrickColor.new("Mulberry")
    local EC = BrickColor.new("Grime")
    local IA = BrickColor.new("Crimson")
    local ISD = BrickColor.new("Dusty Rose")
    local MAD = BrickColor.new("Deep orange")
    local MTF = BrickColor.new("Storm blue")
    local ScD = BrickColor.new("Deep blue")
game.Players.PlayerAdded:Connect(function(plr)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local rank = Instance.new("StringValue")
    rank.Name = "Rank"
    rank.Value = rankTbl[plr.UserId]  or "N/A" -- if rankTbl[plr.UserId] is nil pass 'N/A'
    rank.Parent = stats -- safe to do since stats has a nil parent ie not ingame

    local drank = Instance.new("StringValue")
    drank.Name = "Divisional Rank"
    drank.Value = "N/A"
    drank.Parent = stats

    -- When a player join
    if plr.Name == "tictac67" then -- Check player's name
    plr.TeamColor = SD
    elseif
        plr.Name == "tolly67p" then -- Check player's name
    plr.TeamColor = ET
    elseif
        plr.Name == "MINECRAFT_LOLBUILDZ" then
    plr.TeamColor = MD
    elseif
        plr.Name == "JackPlaysRBYT" then
    plr.TeamColor = CD
    elseif
        plr.Name == "consentlaw" then
    plr.TeamColor = FP


end
-- Want this to refresh --
    if plr.UserId == 26331361 then
        drank.Value = "Overseer"
    elseif plr.UserId == 26332121 and plr.Team.Name == "Engineering and Technical" then
        drank.Value = "Director"
    end

-- Refresh stop here --

    -- set stats parent after setup is complete
    stats.Parent = plr
end)


0
maybe like game.Players.PlayerAdded:Connect(function(plr) end) ? RubenKan 3615 — 6y
0
I already have that. That is just when the player joins tictac67 96 — 6y
0
Player:GetPropertyChangedSignal("Team"):Connect() ... ee0w 458 — 6y
0
Your comment got cut off or did you mean to put ... tictac67 96 — 6y
0
It does not work tictac67 96 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

So, you want to add this at the start so the script will check whenever a player joins a team. ~~~~~~~~~~~~~~~~~ if game.Teams.["TEAM HERE","TEAM HERE","etc"].PlayerAdded:connect (function(player) then --SCRIPT HERE end) ~~~~~~~~~~~~~~~~~ After then will be the rest of the script. So, game.Teams refers to the teams folder in game. Then .["Mobile Task Force"]PlayerAdded:connect (function(player) end) refers to the team and when a player is added. You need an end due to the function.

Ad

Answer this question