Hello i was working on a Gui button if you click it and you got the right rank in the group you wil be tped to a spawn of the team and be set automatic in the team it works fine the only problem i have is it wont Set me in the team and just let me stand in the normal team where every player can spawn anyone how to fix this ?
Code:
local requiredRankMinimum = 255 --To get rank IDs, look in your group admin page.
local Players = game:GetService ("Players")
local plr = Players.LocalPlayer
function Click(mouse)
if plr:GetRankInGroup(8514400) >= requiredRankMinimum then
local function onPlayerAdded(player)
plr.TeamColor = BrickColor.new("Really red") -- TeamColor is Cap sensitive.
end
local Background = script.Parent.Parent.Parent
local Fade = Background.Parent.Fade
wait(.1)
Fade.Visible = true
for i = 1,50 do
Fade.BackgroundTransparency = Fade.BackgroundTransparency - .05
wait()
end
wait(.3) --Change to time you want the Fade frame appear for.
Background.Visible = false
game.ReplicatedStorage.TeamChoosingEvent:FireServer(script.Parent.Name)
plr.Character:MoveTo(game.Workspace.Founder.Position)
wait(.01)
for i = 1,50 do
Fade.BackgroundTransparency = Fade.BackgroundTransparency + .05
wait()
end
Fade.Visible = false
end
end
script.Parent.MouseButton1Click:connect(Click)