Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I give players random tools when they spawn?

Asked by 4 years ago

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.

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

2 answers

Log in to vote
0
Answered by 4 years ago

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

01--randomizer, place items in serverstorage
02 
03players = game.Players:GetChildren()
04items = game.ServerStorage:GetChildren()
05 
06while wait(120) do -- Every 2 Minutesit will clone a random tool, and give it to the players
07    if #players > 1 then
08        for i = 1,#players do
09        clone = items[math.random(1,#items)]:Clone()
10        clone.Parent = players[i]
11        end
12    end
13end
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. TheBuliderMC 84 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

Just put the tools in the StarterPack. :P

Answer this question