✓ Accepted answer
The StarterPack is not the place where the Player's tools are stored, they move to the Player's Backpack after the game runs. To remove tools from all players, you can do this.
for _,player in pairs(game.Players:GetChildren()) do
for _,tool in pairs(player.Backpack:GetChildren()) do
tool.Parent = ServerStorage:FindFirstChild("itemholder")
end
end
This way, the tools get mixed up and you won't be able to give them back later, to fix this, you can add this in a server script:
local holder = ServerStorage:WaitForChild("itemholder")
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.New("Folder")
folder.Name = player.Name
folder.Parent = holder
end)
game.Players.PlayerRemoving:Connect(function(player)
local folder = holder:FindFirstChild(player.Name)
if folder then
folder:Destroy()
end
end)
So, Your final script to remove all the tools from the players would be
for _,player in pairs(game.Players:GetChildren()) do
for _,tool in pairs(player.Backpack:GetChildren()) do
tool.Parent = ServerStorage:FindFirstChild("itemholder"):FindFirstChild(player.Name)
end
end
13 comments
thank u really but this line of code in the server script game.Players.PlayerAdded:Connect(function(player) local folder = Instance.New("Folder") folder.Name = player.Name folder.Parent = holder end) gives me serverScriptService.main:67: attempt to call a nil value
does itemholder exist in the serverstorage?
yes it does
but should i put the for _,player in pairs(game.Players:GetChildren()) do 2 for _,tool in pairs(player.Backpack:GetChildren()) do 3 tool.Parent = ServerStorage:FindFirstChild("itemholder"):FindFirstChild(player.Name) in local or server because i have put it into a server script
and when i play my game i can not open the server storage folder in explore is it a normal thing or does it mean that threre is nothing in it
try using replicatedstorage instead of serverstorage
ok thanks
thank you oilkas it worked really thank you
the tolls dissapear but it still shows the error is it a big deal
what is the error?
the same error erverScriptService.main:67: attempt to call a nil value thiis line local folder = Instance.New("Folder")
thats odd
maybe i should create the itemholder in my script