What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Ive tried many, like this script, but it doesnt seem to work.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local function onCharacterAdded(character)
local function onPlayerAdded(player)
local tools = player.Backpack:GetChildren()
for _,v in ipairs(player.Character:GetChildren()) do
if v.ClassName=="Tool" then
tools[#tools+1]=v
end
end
table.sort(tools,function(a,b) return a.SortVal.Value<b.SortVal.Value end)
for _,t in ipairs(tools) do t.Parent=nil end
wait()
for _,t in ipairs(tools) do t.Parent=player.Backpack end
end
end
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Well, first off, onPlayerAdded can’t be called instead onCharacterAdded. You’ll need to define the function onCharacterAdded before defining onPlayerAdded.
This script below might work. I haven’t tested it, so try this and if it doesn’t work reply to me so I can fix it.
local Players = game:GetService("Players")
local function onCharacterAdded(character)
local tools = player.Backpack:GetChildren()
for _, v in pairs(player.Character:GetChildren()) do
if v.ClassName=="Tool" then
tools[#tools+1]=v
end
end
table.sort(tools,function(a,b)
return a.SortVal.Value<b.SortVal.Value
end)
for _,t in pairs(tools) do
t.Parent=nil
end
wait()
for _,t in pairs(tools) do
t.Parent = player.Backpack
end
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
local function sortBackpack()
humanoid:UnequipTools()
local tools = backpack:GetChildren()
for _, tool in ipairs(tools) do
tool.Parent = nil
end
table.sort(tools, function(leftTool, rightTool)
return leftTool.SortValue.Value < rightTool.SortValue.Value
end)
for _, tool in ipairs(tools) do
tool.Parent = backpack
end
end