did this in server script service in a regular script
local key = game.Workspace.Keycard
local clickDetector = Instance.new(“ClickDetector”)
local plr = game:GetService(“Players”).LocalPlayer
local function onMouseClick(player)
key:Clone()
end
clickDetector.Parent = key
key.Parent = plr.Backpack
clickDetector.MouseClick:connect(onMouseClick)
output error: attempt to index local ‘plr’ a nil value |