Room Key System Not Working

Hello, I am trying to make a Room Keycard system but I am coming up on some difficulties.

  • The system itself somewhat works, since I get the tool and the tool gets the name, but the ToolTip is just nil, and there is no output message or error.

local Repl = game:GetService("ReplicatedStorage")
local GiveRoom = Repl.Events.GiveRoom

local Players = game:GetService("Players")
local RoomMetadata = {
	
	TotalRooms = {};
	AvailebleRooms = 12;
	StartRoom_Number = 100;
};

Players.PlayerAdded:Connect(function(Player)
	local HasRoom = Instance.new("BoolValue")
	local RoomNumber = Instance.new("NumberValue")
	
	HasRoom.Parent = Player
	RoomNumber.Parent = HasRoom
	
	HasRoom.Name = "HasRoom"
	RoomNumber.Name = "RoomNumber"	
end)

GiveRoom.OnServerEvent:Connect(function(Player, value)
	local Room_KeyTemplate = Repl.KeyTemplate
	
	if not table.find(RoomMetadata.TotalRooms, value) then
		table.insert(RoomMetadata.TotalRooms, value)
		RoomMetadata.AvailebleRooms -= 1
		
		
		local Key = Room_KeyTemplate:Clone()
		
		Key.Parent = Player:WaitForChild("Backpack")
		Key.ToolTip = tostring(value)
		Key.Name = "Room Key"
	else
		return false		
	end
end)
1 Like

Did you use a Local Script or a Server Script?

Server script since it handles the event, and used a local script to fire the event through a GUI Button.

So, I gathered some info. I completed the tool giving like you did with GUI button.
The only reason it was nil was because you never specified your tostring(value)

1 Like

What do you mean I never specified my tostring?

Why do you have rep.events.giveroom why not just
Rep.giveroom? Or does giveroom have a parent

Because I organized and store all of my events in a Folder called “Events”.

2 Likes

the value for your string was never mentioned inside the script.

Actually the value, is a event argument, and in my local script I fired the event using the proper argument.

You should try placing the value inside the Server Script as it only runs the event through that script.