Guest User

Untitled

a guest
Sep 21st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. local teams = game:GetService("Teams")
  2. local settings = {
  3. ["GUIHeight"] = 30, --put in a number over 20, or 100 if you want it to fill the screen
  4. ["GUIWidth"] = 40, --put in a number over 20, or 100 if you want it to fill the screen
  5. ["GUIColor"] = Color3.fromRGB(240,240,240), --color of the team changer gui
  6.  
  7. ["TitleText"] = "Team Changer", --title text in the gui
  8. ["TitleFont"] = "ArialBold", --font of title
  9. }
  10.  
  11. repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.PlayerGui
  12. local plr = game.Players.LocalPlayer
  13.  
  14. local teamGUI = Instance.new("ScreenGui",plr.PlayerGui)
  15. local frame = Instance.new("Frame",teamGUI)
  16. frame.AnchorPoint,frame.Size,frame.Position,frame.BackgroundColor3 = Vector2.new(0.5,0.5),UDim2.new(settings.GUIWidth/100,0,settings.GUIHeight/100,0),UDim2.new(0.5,0,0.5,0),settings.GUIColor
  17.  
  18. local title = Instance.new("TextLabel",frame)
  19. title.Text,title.Font,title.Size,title.TextScaled,title.BackgroundTransparency = settings.TitleText,settings.TitleFont,UDim2.new(1,0,0.15,0),true,0.5
  20.  
  21. local closebutton = Instance.new("TextButton",title)
  22. closebutton.Size,closebutton.Position,closebutton.BackgroundColor3,closebutton.Text = UDim2.new(0.1,0,1,0),UDim2.new(0.9,0,0,0),Color3.fromRGB(255,155,155),"Close"
  23.  
  24. local list = Instance.new("ScrollingFrame",frame)
  25. list.Size,list.Position,list.BackgroundTransparency = UDim2.new(1,0,0.85,0),UDim2.new(0,0,0.15,0),1
  26.  
  27. local UILayout = Instance.new("UIListLayout",list)
  28.  
  29. local serverTeamHandler = game.ReplicatedStorage:WaitForChild("teamChanger")
  30. local getTeams = teams:GetChildren() --this part checks if you have teams in your game (you need to have put the teams in your game already)
  31. for i,v in pairs(getTeams) do
  32. print("[Team " .. i .. " found]: " .. v:GetFullName())
  33. local teamButton = Instance.new("TextButton",list)
  34. teamButton.BackgroundColor3 = v.TeamColor.Color
  35. teamButton.Size = UDim2.new(1,0,0,40)
  36.  
  37. teamButton.Text,teamButton.TextColor3,teamButton.TextStrokeTransparency,teamButton.TextScaled = v.Name,Color3.fromRGB(255,255,255),0.7,true
  38. teamButton.MouseButton1Down:connect(function()
  39. print("You changed teams. You are now in: " .. v.Name)
  40. serverTeamHandler:InvokeServer(v)
  41. end)
  42. end
  43.  
  44. closebutton.MouseButton1Click:connect(function()
  45. frame:TweenPosition(UDim2.new(0.5,0,2,0),"Out","Quad",0.5)
  46. local returnButton = Instance.new("TextButton",teamGUI)
  47. returnButton.Size,returnButton.Position,returnButton.Text,returnButton.TextScaled = UDim2.new(0,200,0,50),UDim2.new(0.5,-100,1,-50),"Open Team Changer",true
  48. returnButton.MouseButton1Down:connect(function()
  49. returnButton:Destroy()
  50. frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Elastic",1,true)
  51. end)
  52. end)
  53.  
  54. local teamChanger = Instance.new("RemoteFunction",game.ReplicatedStorage)
  55. teamChanger.Name = "teamChanger"
  56.  
  57. local function changeTeam(client,team)
  58. print(client.Name .. "changed teams: now in" .. team.Name)
  59. client.Team = team
  60. end
  61.  
  62. teamChanger.OnServerInvoke = changeTeam
Add Comment
Please, Sign In to add comment