Sooo i have a problem on my script
local gui = script.Parent
local Player = game.Players.LocalPlayer
local slot1 = script.Parent.s1
local slot2 = script.Parent.s2
local slot3 = script.Parent.s3
local slot4 = script.Parent.s4
local check1 = slot1.check.Value
local check2 = slot2.check.Value
local check3 = slot3.check.Value
local check4 = slot4.check.Value
while true do
local Tool1 = Player.Backpack:FindFirstChild("Key") or Player.Character:FindFirstChild("Key")
local Tool2 = Player.Backpack:FindFirstChild("Key2") or Player.Character:FindFirstChild("Key2")
local Tool3 = Player.Backpack:FindFirstChild("Key3") or Player.Character:FindFirstChild("Key3")
local Tool4 = Player.Backpack:FindFirstChild("Map") or Player.Character:FindFirstChild("Map")
if Tool1 then
if check1 == false then
slot1.key.Visible = true
check1 = true
else
if check2 == false then
slot2.key.Visible = true
check2 = true
else
if check3 == false
then
slot3.key.Visible = true
check3 = true
else
if check4 == false
then
slot4.key.Visible = true
check4 = true
else
print("No Space")
end
end
end
end
end
wait()
end
So in this script, i've wanted to make a slots for tools the check1,check2,check3,check4 is a bool value that is false. So I've wanted to make when the tool1 is in your backpack the if statement will work
so if check1 is false (Empty) then slot1 will make the key icon appear but the problem is when I collect the Tool all the slots have the key icon appeared Idk how it's possible because
Else part will only run if check1.value is true but all the slots have a key icon on all of it
So basically I wanna make a Custom Inventory using these things because I still don't know how to use Tables
Note: I wanna make The Key Icon appear on an Empty slot, If Bool Value is false it means its empty but if its true it means it's not empty so it will proceed to another slot then check if its Bool Value is False but if isn't it will proceed to another slot etc.

2 comments
Well i see the problem its because of the While true do Loop but how can i fix this though whats substitute than the loop?
elseif and else if have two different meanings https://www.lua.org/pil/4.3.1.html