How To Make Team Picker (ROBLOX STUDIO)

Опубликовано: 27 Февраль 2025
на канале: ShaboNeeno
3,413
93

In this video, I quickly show you how to make a team picker for your Roblox game! Requires no scripting and is easy to do.
Model: https://create.roblox.com/store/asset...

Local Script:
local repStorage = game:GetService('ReplicatedStorage')
local players = game:GetService('Players')
local teams = game:GetService('Teams')

local red = teams:WaitForChild('Red')
local blue = teams:WaitForChild('Blue')
local choosingTeam = teams:WaitForChild('Choosing')

local chooseEvent = repStorage:WaitForChild('ChooseTeam')
local plr = players.LocalPlayer
local screenGui = repStorage:WaitForChild('ScreenGui')

screenGui.ResetOnSpawn = false
screenGui.Parent = plr:WaitForChild("PlayerGui")

local function showPicker()
if plr.Team == choosingTeam then
screenGui.Enabled = true
else
screenGui.Enabled = false
end
end

showPicker()

plr:GetPropertyChangedSignal('Team'):Connect(showPicker)

local blueButton = screenGui.Frame.BlueButton
local redButton = screenGui.Frame.RedButton

blueButton.MouseButton1Click:Connect(function()
chooseEvent:FireServer(blue)
end)

redButton.MouseButton1Click:Connect(function()
chooseEvent:FireServer(red)
end)

Server Script:
local repStorage = game:GetService('ReplicatedStorage')
local players = game:GetService('Players')
local teams = game:GetService('Teams')

local red = teams:WaitForChild('Red')
local blue = teams:WaitForChild('Blue')
local choosingTeam = teams:WaitForChild('Choosing')

local chooseEvent = repStorage:WaitForChild('ChooseTeam')

local function onEvent(playerFrom,teamChosen)
if teamChosen == red then
playerFrom.Team = red
elseif teamChosen == blue then
playerFrom.Team = blue
else
playerFrom.Team = choosingTeam
if playerFrom.Character then
playerFrom.Character:Destroy()
end
return
end
playerFrom:LoadCharacter()
end

local function onPlayerJoined(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild('Humanoid')
humanoid.Died:Once(function()
task.wait(players.RespawnTime)
if player.Character == character then
player:LoadCharacter()
end
end)
end)
--- OPTIONAL, UNCOMMENT THE CODE BELOW IF YOU WANT TO ALLOW PLAYERS TO SWITCH TEAMS WHILE PLAYING!

--player.Chatted:Connect(function(message)
-- if string.lower(message) == '/e pick team' then
-- onEvent(player,choosingTeam)
-- end
--end)
end

chooseEvent.OnServerEvent:Connect(onEvent)
players.PlayerAdded:Connect(onPlayerJoined)

If this tutorial helped you make sure to slap that like button and punch the subscribe button for more tutorials like this one!