Hi I am making a mini game sort of type game, and I basically want to random give players different weapons so for example if the theme is bows then one player would get a blue bow the other would get a green bow etc.
weapons and everything is done, but do not know how to give the players only 1 weapon randomly.
This is my part of script where I define the weapons, all I need to do is to give the randomly chosen weapon to the players.
local WepTheme = game.ServerStorage.Weapons:GetChildren()
local ChosenWepTheme = WepTheme[math.random(1,#WepTheme)]
ChosenWepTheme:GetChildren()
local getWeapons = game.ServerStorage.Weapons:GetChildren()
local list = {}
for i, parts in pairs(getWeapons) do
table.insert(list, math.random(1, #getWeapons))
end
print(list[1])
how do I give them only 1 weapon from the list, also I think you will have to remove that weapon that has been given from the list so multiple players don’t get the same weapon.
local WepTheme = game.ServerStorage.Weapons:GetChildren()
local ChosenWepTheme = WepTheme[math.random(1,#WepTheme)]
local weps = ChosenWepTheme:GetChildren()
for i, player in pairs (game.Players:GetPlayers()) do
local weapon = table.find(weps, math.random(1, #weps))
local giveWeapon = weapon:Clone()
giveWeapon.Parent = player:WaitForChild("Backpack")
end