local function PlayerAdded(player)
for i, v in pairs(player:WaitForChild("OwnedTools"):GetChildren()) do
print(v.Name)
if player.CurrentTool.Value == v.Name then
print("Player use tool as current")
player.Backpack:ClearAllChildren()
wait(.5)
local clonedTool = Items:FindFirstChild(player.CurrentTool.Value):Clone()
clonedTool.Parent = player.Backpack
clonedTool.Name = player.CurrentTool.Name
end
end
end
game.Players.PlayerAdded:Connect(PlayerAdded)
You’re doing :WaitForChild("OwnedTools"), and then getting the children of OwnedTools right away. There is a high likelihood that right when it finds the folder, no tools exist in it yet, thus rendering your in pairs loop useless.
If you want to test my theory, add a task.wait(5) right under local function PlayerAdded(player), if it then starts to print the actual tools in the folder, this is your issue. I wouldn’t recommend waiting 5 seconds for actual in game production, I’m simply saying this is a debugging tool you can use.
Yes, that is expected. You’re checking if you own the tools right when you join, but you don’t have the tools when you join, therefore nothing happens.