I've tried making an item where if you press E with your mouse over it, the tool in game.Lighting gets cloned and goes into your inventory. I've tried using mouse.Target and mouse.KeyDown to possibly make this happen, but the Output always puts these errors: "Attempt to connect failed: Passed value is not a function" and "attempt to call a nil value" <- This one occurs everytime I make a movement.
mouse = game.Players.LocalPlayer:GetMouse()
player = game.Players.LocalPlayer
enabled = true
itemname = nil
mouse.Move:Connect(function()
if mouse.Target then
if mouse.Target.Parent:FindFirstChild("ItemValue") then
itemname = mouse.Target.Name
function onKeyPress(inputObject, gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.E then
if player.Backpack:findFirstChild(itemname) == true then
if enabled == true then
enabled = false
local itemclone = game.Lighting[itemname]:clone()
itemclone.Parent = player.Backpack
enabled = true
end
end
end
end
end
else
itemname = nil
end
else
end
end)
