Tool not being given when event fired

Hi, so I’m making a Check-in system so I can have one for my hotel!
The only issue is, it doesn’t work.

The issue is, it’s not giving the Keycard.
The event fires perfectly, it just doesn’t give the card.

I’ve tried making multiple keys, that didn’t work and I didn’t get any output errors.
Where have I gone wrong?

local Tool = game.ServerStorage.S101
local ToolClone = Tool:Clone()
local Handle = ToolClone.Handle


local rooms = {
	S101 = nil,
	S102 = nil,
	S103 = nil
}

game.ReplicatedStorage.CheckIn.OnServerEvent:Connect(function(plr, name, reason)
	for i, thePlr in pairs(game.Players:GetChildren()) do
		if string.match(thePlr.Name, name) then
			for i, v in pairs(rooms) do
				if v == thePlr.Name then
					return
				end
			end
			for room, v in pairs(rooms) do
				if v == nil then
					v = thePlr.Name
					local ToolClone = Tool:Clone()
					local Handle = ToolClone.Handle
					ToolClone.Parent = thePlr.Backpack
					ToolClone.Name = i
				end
			end
		end
	end
end)

Setting the value of a dictionary key to be nil removes that key from the dictionary, so rooms is an empty table and the code in the two for loops where it’s used doesn’t run at all. You could use false instead of nil.

1 Like

Oh, ok! Thanks, I understand now.
Thanks!