local gunToGet = script.Parent.Parent.Parent.Parent.Spin.SpinnerFrame.Frame["18"].Gun.Value
if game.Players.LocalPlayer.Slot1.Value ~= "Empty" then
if game.Players.LocalPlayer.Slot2.Value ~= "Empty" then
if game.Players.LocalPlayer.Slot3.Value ~= "Empty" then
if game.Players.LocalPlayer.Slot4.Value ~= "Empty" then
print("full inventory")
elseif game.Players.LocalPlayer.Slot4.Value == "Empty" then
game.Players.LocalPlayer.Slot4.Value = gunToGet
end
elseif game.Players.LocalPlayer.Slot3.Value == "Empty" then
game.Players.LocalPlayer.Slot3.Value = gunToGet
end
elseif game.Players.LocalPlayer.Slot2.Value == "Empty" then
game.Players.LocalPlayer.Slot2.Value = gunToGet
end
elseif game.Players.LocalPlayer.Slot1.Value == "Empty" then
game.Players.LocalPlayer.Slot1.Value = gunToGet
end
This script is supposed to go through each inventory space and check to see if it's empty, if it isn't it goes to the next and keep going until it reaches one that is empty so it can set that space to whatever it needs to be set to. The problem is that I have extended the inventory from 4 spaces to 50 so obviously that'll be a lot of lines to get the script to check each one... Is there any way to fix it so that it can check through each one and select the first empty one with a much more organized script?

4 comments
It's working alright, but for some reason it's skipping certain numbers. Specifically 9 and 13 from when I tested it.
@Scootakip Is the naming consistant?
Nope, looked back at the save data creator and noticed that "Empty" was spelled wrong for 9 and 13. Thanks.
@Scootakip Glad I could help