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.

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

Log in to vote
0
Answered by 4 years ago

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
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