#code random Tools

1 messages · Page 1 of 1 (latest)

restive forum
#

code random part

#

Can anyone give me a code that will give random tools to players when entering the game?

#

code random Tools

jaunty agate
#

ok sure

mental crowBOT
#

studio** You are now Level 2! **studio

jaunty agate
#

local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Folder = RS:WaitForChild("Weapons")
-- Change the "Weapons" if you change the folder name in Replicated Storage

local function onCharacterAdded(character)
local Tools = Folder:GetChildren()
local ToolsTable = Tools
local chosenTools = {}

repeat
    local selectedIndex = math.random(1, #ToolsTable)
    table.insert(chosenTools, ToolsTable[selectedIndex])
    table.remove(ToolsTable, selectedIndex)
until #chosenTools >= 3 -- Numbers of tools going to give

local plr = Players:GetPlayerFromCharacter(character)
for i,v in pairs(chosenTools) do
    Folder:FindFirstChild(v.Name):Clone().Parent = plr.Backpack
end

end

local function onAdded(player)
player.CharacterAdded:Connect(onCharacterAdded) -- Triggers when the player spawns or respawns
end

Players.PlayerAdded:Connect(onAdded)

restive forum
#

thanks you verry mushhh