OnFireRobloxScriptin

Team Change System Server Script

Jul 26th, 2025 (edited)
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 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. local Teams = game:GetService("Teams") --Teams
  5.  
  6. TeamChangeEvent.OnServerEvent:Connect(function(player, teamName) --When server recieves Remote Event, get the player and team name
  7.     local team = Teams:FindFirstChild(teamName) --Find team using team name
  8.     if team then --if team exists
  9.         player.Team = team --change player's team to desired team
  10.         player.TeamColor = team.TeamColor --change player's team color to desired color
  11.     end
  12. end)
Advertisement
Add Comment
Please, Sign In to add comment