This is very tough to explain, I myself took some time trying to make a title. I'm trying to make a pickUp Script and I'm having trouble with the drop portion. I will admit there are definitely flaws, I just sorta went along with it, so I will post the whole Event. Basically, there are 3 undefined carrierSlots; CFrame positions, on the Character at the moment, and the drop function is to index whichever Item is currently in the Slot# that was received by UserInput. The sequence is supposed to go somewhat like this: Holding E - Slot Index (1-3), Right Click. The first two keys are supposed to be held down, Right Click will "drop" the Indexed Item wherever the cursorPoint is currently located.
I have a table that looks like so
local carrierSlotIndex = {
["1"] = "One";
["2"] = "Two";
["3"] = "Three";
};
these are the carrierSlotIndex keys
This is the concatenation line
userInputService:IsKeyDown(
Enum.KeyCode[carrierSlotIndex[inputObject]]
)
This is the Script
userInputService.InputBegan:Connect(function(inputObject, gameProcessed)
local cursorPoint = cursor.Hit.p
if (userInputService:IsKeyDown(Enum.KeyCode.E) and not gameProcessed) then
if (userInputService:IsKeyDown(Enum.KeyCode[carrierSlotIndex[tostring(inputObject)]])) then
if (type(inputObject) == "number") then
for _,inputObject_ in ipairs(carrierSlotIndex) do
if (inputObject_ ~= carrierSlotIndex) then
return false
end
if (cursorPoint ~= cursorPoint) then cursorPoint = cursor.Hit.p end
print("Dropped Item")
local carrierItems = carrierInventory:GetChildren()
local carrierItem = carrierItems[inputObject]
if (carrierItem ~= nil) then
if (inputObject.UserInputType == Enum.UserInputType.MouseButton2) then
local weld = findObject(carrierItem,"Weld", "weld")
if (weld) then weld:Destroy() end
local setSlickDetector Instance.new("ClickDetector"); setSlickDetector:Clone().Parent = carrierItem
carrierItem.CFrame = CFrame.new(0,0,0)
carrierItem.Parent = workspace
carrierItem.Position = cursorPoint
carrierItem.Anchored = true
break
end
end
end
end
end
end
end)
This question is quite a lot so I'd really appriciate to whomever can provide a working answer, I'll accept it right off the bat and upvote too! Thanks!
If there is anything confusing about my explanation, please feel free to ask me to elaborate
I've also done some testing and removed tostring() from the concatenation line. I now got
bad argument #2 to '?' (string expected, got nil)
what am I doing wrong?!

8 comments
I dont know the answer but i applaud how well you've explained the question.
Thanks
This will not work. 'inputObject' is just an instance (like parts, scripts, models, etc) with the KeyCode and UserInputType and all those properties.
InputObject is the key pressed right?
A, B, C, you can concatenate this with Enum.KeyCode then by saying Enum.KeyCode[inputObject]
InputObject when it comes to numbers isn't "One" "Two" is 1, 2, so I'm making this index the item in the table to make it read Enum.KeyCode.One
like incapaxian said, InputObject is an object which holds properties of the input
How can I use it THEN?