What I am talking about and trying to figure out is, first, let's start off with some information. I am newly remaking my game into a hotel, and I am currently in the process of scripting check-in systems self-made by me. What I am also trying to figure out is how to make it so that only 1 player can get an item in their inventory and that multiple players can't have that item all at once, for example, the room keycard. The keycard is scripted to open the door and all the other stuff, but how do I make it so that only 1 player can have the keycard. I have a GUI in StarterGui for self check-in, which allows to check into listed rooms, and whenever they click this button I made called "Room 101", it gives them a handle/part inside their backpack/inventory, named "Room 101". How do I make it so that if the handle is already in somebody else's inventory, whenever anybody else clicks the "Room 101" button, it doesn't give them anything, instead pops out with a frame, that has a textlabel inside of it that says "This room is taken!"? If any other information is needed to answer this, here are the scripts I used.
REPLICATED STORAGE
Folder named "cardStorage"
cardStorage
6 tools: Room101 Room102 Room103 Room104 Room105 Room106
STARTERGUI
ScreenGUI named "sfcGui" which stands for "selfcheckinGui"
sfcGui
1 main local script: sfcHandler(IMPORTANT) 5 frames: mainFrame(Frame with button that says "Get Started") (NOT IMPORTANT) ticketFrame(List with all classes including Presidental, Suite and standard) (NOT IMPORTANT) standardFrame(List of all the rooms, buttons that say "ROOM#" on it) (NOT IMPORTANT) topBar(Title) (NOT IMPORTANT) endFrame(GUI that pops up when you check-in) (NOT IMPORTANT)
Here's the script for the sfcHandler(STILL IN PROGRESS):
local plr = game:GetService("Players").LocalPlayer local gui = script.Parent local mainFrame = gui:WaitForChild("mainFrame") local ticketFrame = gui:WaitForChild("ticketFrame") local endFrame = gui:WaitForChild("endFrame") local standardFrame = gui:WaitForChild("standardFrame") local scRE = game:GetService("ReplicatedStorage"):WaitForChild("scRE") local suiId = 1 local psId = 1
--// functions mainFrame:WaitForChild("startBtn").MouseButton1Click:connect(function() mainFrame.Visible = false ticketFrame.Visible = true end)
ticketFrame:WaitForChild("stBtn").MouseButton1Click:connect(function() ticketFrame.Visible = false standardFrame.Visible = true end)
standardFrame:WaitForChild("Room101").MouseButton1Click:connect(function() scRE:FireServer("giveRoom101", plr) standardFrame.Visible = false endFrame.Visible = true end)
standardFrame:WaitForChild("Room102").MouseButton1Click:connect(function() scRE:FireServer("giveRoom102", plr) standardFrame.Visible = false endFrame.Visible = true end)
standardFrame:WaitForChild("Room103").MouseButton1Click:connect(function() scRE:FireServer("giveRoom103", plr) standardFrame.Visible = false endFrame.Visible = true end)
standardFrame:WaitForChild("Room104").MouseButton1Click:connect(function() scRE:FireServer("giveRoom104", plr) standardFrame.Visible = false endFrame.Visible = true end)
standardFrame:WaitForChild("Room 105").MouseButton1Click:connect(function() scRE:FireServer("giveRoom105", plr) standardFrame.Visible = false endFrame.Visible = true end)
standardFrame:WaitForChild("Room106").MouseButton1Click:connect(function() scRE:FireServer("giveRoom106", plr) standardFrame.Visible = false endFrame.Visible = true end)
endFrame:WaitForChild("closeBtn").MouseButton1Click:connect(function() gui:Destroy() end)
scRE is a remote event in replicated storage by the way.
Please tell me soon how to make this work.

3 comments
Please... Use a code block. It hurts to read these codes without the code block.
Do you want it to be random, or a certain person?
random