I put a normal script into a dialogue choice so when a player clicks on it they get a keycard. Why didn't it work?

local rep = game:GetService("ReplicatedStorage")
local key = rep:FindFirstChild("Keycard")

local player = game.Players.LocalPlayer


workspace.Dialog.DialogChoiceSelected:connect(function(player,choice)
	if choice.Name == "Keycard please!" then
		key:Clone().Parent = player
	end
end)