how would i put a random gear from server storage into the players backpack each time they respawn? (a different gear every respawn) i cant code all to well and the most i can do is edit a script, i cant write my own.
Put all your items into a folder called "Items" in replicated storage, then run this code inside server script service.
local players = game:GetService("Players") local items = game.ReplicatedStorage:WaitForChild("Items) -- You can use server storage, it is just that the client cant access server storage. players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() --This also runs every time the player dies. local backpack = player.Backpack local children = items:GetChildren() --Gets the children local random = math.random(1,#children) -- I think at arrays start at 0, so change to 1 or 0 based on if this works or not. local child = children[random] local clone = child:Clone() clone.Parent = backpack end) end)
This code is untested. But the thought behind it is that when a character spawns, it gives them a random item.
I'll try to give you a script to work out.
local ServerStorage = game:GetService("ServerStorage") -- Create a folder in ServerStorage and put the tools in there and name it ToolsFolder local ToolFol = ServerStorage:FindFirstChild("ToolsFolder") local Tools = ServerStorage.ToolsFolder:GetChildren() game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) local hum = char:WaitForChild("Humanoid") hum.Died:Connect(function() plr:LoadCharacter() local ToolinChar = char:FindFirstChildOfClass("Tool") local ToolinBack = plr.BackPack:FindFirstChildOfClass("Tool") local rannum = math.random(1, #Tool) if ToolinChar then ToolinChar:Destroy() elseif ToolinBack then ToolinBack:Destroy() end if rannum == 1 then local ClonedTool = ToolFol:FindFirstChild("ToolNameInHere") ClonedTool.Parent = char.BackPack elseif rannum == 2 then local ClonedTool = ToolFol:FindFirstChild("ToolNameInHere") ClonedTool.Parent = char.BackPack elseif rannum == 3 then local ClonedTool = ToolFol:FindFirstChild("ToolNameInHere") ClonedTool.Parent = char.BackPack elseif rannum == 4 then local ClonedTool = ToolFol:FindFirstChild("ToolNameInHere") ClonedTool.Parent = char.BackPack -- Add as many elseif statements for how many tools in the tool folder... end print("Gave A Player a new Tool On Death!") end) end) end)
Try that and if it doesn't work, please comment below!