So I want to be able to type in a players user name in a text box and a room number for the keycard (its for a hotel). I know how I can do that but I am just not sure how to actually give the item to them and how to give it to the player I am referencing. What I mean is I can check the textbox for the name that the staff would of typed in but and the room number but how would I be able to actually put the keycard that is typed in into the players backpack. Please help. Thank you! -TheWubbles123
I don't know if this is a proper answer but,
a =label.Text -- fix this if a == item.Name then -- place in inventory elseif -- and so on end
So here's what you can do:
local item = {} -- Put the item directory here. local textButton = {} -- Put the directory of the TextButton. local textBox = {} -- Put the directory of the TextBox. local function giveItem(player) local findPlayer = game.Players:FindFirstChild(player) if findPlayer then if item then local clonedItem = item:Clone() clonedItem.Parent = findPlayer.Backpack else print("No item has been detected.") end end end textButton.MouseButton1Click:Connect(function() giveItem(textBox.Text) end
PS: This is the LocalScript version.
And when you're trying to set the name of the user and room on the card:
local cardInstance = {} -- Put the card directory here. function giveCard(player) local clonedCardInstance = cardInstance:Clone() clonedCardInstance.Parent = player.Backpack local roomText = {} -- Put the directory that the Room Text on the card is on. local userText = {} -- Put the directory that the name of the Player text on the card is on. userText.Name = player.Name end
PS: This is the server script version, add it to the card-giver script.