I re-worded this, how would I be able to select a random player on a team and give them a tool?
COMMUNITY QUESTION
How do I select a random player in a team?
2 answers
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
It tells me on line 10, "invalid argument #2 to 'random' (interval is empty)", I'm not a pro at stuff like this so I don't know what to do about it.