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 give players random tools when they spawn?

This script does work, but sometimes it doesn't at all. Every time I respawn or someone respawns, they have a high chance of not receiving the tool.

game.Players.PlayerAdded:connect(function(p) 
p.CharacterAdded:connect(function(c) 
repeat 
wait() 
until p:FindFirstChild("Backpack") 
game.ServerStorage:GetChildren()[math.random(1, #game.ServerStorage:GetChildren())]:clone().Parent = p.Backpack 
end) 
wait(2)
end) 

2 answers

Try This, make sure to put all your tools in Server Storage:

--randomizer, place items in serverstorage

players = game.Players:GetChildren()
items = game.ServerStorage:GetChildren()

while wait(120) do -- Every 2 Minutesit will clone a random tool, and give it to the players
	if #players > 1 then
		for i = 1,#players do
		clone = items[math.random(1,#items)]:Clone()
		clone.Parent = players[i]
		end
	end
end

1 comment

0

This works, but this doesn't solve my problem. I need to figure out how to prevent players that spawned, spawned with no tools.

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