I re-worded this, how would I be able to select a random player on a team and give them a tool?
Solution
Using the method :GetPlayers() on a team will return a table of players in the team.
Script
local Teams = game:FindService("Teams") local ServerStorage = game:FindService("ServerStorage") local team = Teams.Team local tool = ServerStorage.Tool local function GiveRandomPlayerItem() local randPlayer = team:GetPlayers()[math.random(1,#team:GetPlayers())] tool:Clone().Parent = randPlayer.Backpack end GiveRandomPlayerItem()
Explanation
Finding the Teams
and ServerStorage
services.
A variable for the Team instance and a variable for the tool instance.
A function that will select a random player in the team
and clones the tool
and will set the parent to the specific player's backpack.
You can call the function anywhere in the Script
at any time.
In the end, I made a script which gave the player on the team a tool and a GUI that can only be seen by the player.