im not rly good at scripting and im trying to make a basic inventory. so here is my script which is supposed to sort items (put them into the inventory gui)
local plrname = game.Workspace:WaitForChild("PlayerName") -- a string value with players name inside
local plr = game.Players:WaitForChild(plrname.Value) -- player
local inv = plr:WaitForChild("Inventory") -- custom folder
inv.ChildAdded:Connect(function()
local items = inv:GetChildren()
local itemsnumber = #inv:GetChildren()
if itemsnumber > 0 then
local item = items[1]
item.Parent = script.Parent.Items
for i,v in pairs(script.Parent.Items:GetChildren()) do
if v.Claimed ~= nil then
if v.Claimed.Value == false then
v.Claimed = true
empty = v
return
end
end
end
item.Position = empty.Position
end
end)
not sure but i think it doesnt work because of the return. so what i want to do is when the for i loop finds an empty slot it stops and runs the second part after the loop. any help will be appreciated

3 comments
The return will only stop the if statement, try using a break. So, replace the return with a break?
lemme try
nope