Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a script that will give a SPECIFIC iteam to a random player?

I am working on a game and basicly its a lobby. players get in the game and after like at least 5 players have joined, the game should start. I want a random player to be given a specific costum made sword (already scripted) that they will later on use to kill the victims. I need a script to give the sword to a random player. Please HALPPPP.

1 comment

0

this is not a request site, learn first, do an attempt, if it doesn't, we will be more than happy to help you fix it

1 answer

This isn't a request site, but since you sound new, I'll help you.

local numb = 0
function upd() numb = #game.Players:GetChildren() end
upd()
local sword =  -- put your sword here lol
-- ex: local sword = game.ServerStorage.Sword
game.Players.PlayerAdded:connect(function(p)
-- someone has joined, so update the number count.
upd()
end)
repeat wait() until numb >= 5
-- now, there are atleast 5 people in the game.
local random = game.Players:GetChildren()[math.random(1,#game.Players:GetChildren)]

sword:Clone().Parent = random.Backpack
-- at this point the player has the specific weapon

This script could have been smaller but I had not thought of it.

Next time please atleast try :)

Happy scripting!

1 comment

0

clear answer good job

This discussion is preserved as it was. New answers, comments, and votes are closed.