game.Workspace.key1.ClickDetector.MouseClick:Connect(function() game.Workspace.key1.Parent = game.ReplicatedStorage end)
game.Workspace.key2.ClickDetector.MouseClick:Connect(function() game.Workspace.key2.Parent = game.ReplicatedStorage end)
game.Workspace.key3.ClickDetector.MouseClick:Connect(function() game.Workspace.key3.Parent = game.ReplicatedStorage end)
game.Workspace.key4.ClickDetector.MouseClick:Connect(function() game.Workspace.key4.Parent = game.ReplicatedStorage end)
game.Workspace.key5.ClickDetector.MouseClick:Connect(function() game.Workspace.key5.Parent = game.ReplicatedStorage end)
You can use a table to store all the keys. Then loop through them;
local ToClick = {workspace.key1, workspace.key2, workspace.key3, workspace.key4); for i, Key in pairs(ToClick) do Key.ClickDetector.MouseClick:Connect(function(Player) Key.Parent = game.ReplicatedStorage; end) end