OnFireRobloxScriptin

Team Change System Local Script

Jul 26th, 2025
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. --//Replicated Storage
  2. local replicatedStorage = game:GetService("ReplicatedStorage") --Replicated Storage
  3. local TeamChangeEvent = replicatedStorage:WaitForChild("TeamChange") --Variable for Remote Event
  4.  
  5. --//Variables
  6. local openButton = script.Parent.Open
  7. local background = script.Parent.Background
  8. local redButton = background.Red
  9. local blueButton = background.Blue
  10. local exitButton = background.Exit
  11.  
  12. local function exit() --Function for exiting
  13.     openButton.Visible = true --Makes open button visible
  14.     background.Visible = false --Makes background invisible
  15. end
  16.  
  17. --//Ui Functionality
  18. openButton.MouseButton1Click:Connect(function()
  19.     openButton.Visible = false --Makes open button invisible
  20.     background.Visible = true --Makes background visible
  21. end)
  22.  
  23. exitButton.MouseButton1Click:Connect(function()
  24.     exit()
  25. end)
  26.  
  27. --//Change Teams
  28. redButton.MouseButton1Click:Connect(function()
  29.     TeamChangeEvent:FireServer("Red") --Fires Remote Event to server
  30.     exit()
  31. end)
  32.  
  33. blueButton.MouseButton1Click:Connect(function()
  34.     TeamChangeEvent:FireServer("Blue")
  35.     exit()
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment