i'm using this script in a gun to check the gui for the boolValue and see if the value is checked but the script won't work so when I go to get another gun it allows my player to keep it

while wait() do
script.Parent.Parent.Parent.PlayerGui.Inventory.Frame.Primary.Text = script.Parent.Name
if script.Parent.Parent.Parent.PlayerGui.Inventory.Frame.Primary.Primary.Value.Enabled == true then
script.Parent:remove()
elseif
script.Parent.Parent.Parent.PlayerGui.Inventory.Frame.Primary.Primary.Value.Enabled == true then
end
end