Whenever I click a button, it gives me this error: "Argument 1 missing or nil".
EDIT: I removed the "[1]" at the end of data and no errors popped up but I didn't get the key.
The text button and tool are named the same so if the text button was named "Room201" the tool would also be named "Room 201". I don't know why this doesn't work.
The first script is a server script and the second one is also a server script.
local event = game:GetService("ReplicatedStorage"):WaitForChild("NetworkFolder"):WaitForChild("GiveRoom")
for i,v in pairs(script.Parent.Bed1Frame:GetChildren()) do
v.MouseButton1Click:connect(function()
event:FireServer("give1bed", v.Name)
end)
end
print("YOOOOO")
local event = game:GetService("ReplicatedStorage"):WaitForChild("NetworkFolder"):WaitForChild("GiveRoom")
local tools = game:GetService("ReplicatedStorage"):WaitForChild("Tools")
event.OnServerEvent:connect(function(player, request, data)
print(player, request, data)
if request == "give1bed" then
print("HIIII")
local employee = workspace.screena.Sensor.Employee.Value
tools:FindFirstChild(data):Clone().Parent = employee.Backpack
print("Done")
else
print("what to do?")
end
end)

6 comments
v.Name is not a table, so you shouldn't be indexing it in your server script.
^ The heck are you talking about? The first script? He's looping through all items of Bed1Frame and using v as the value variable. That loop is perfectly valid.
In the first script (local) v is a child, a Roblox object, but the event:FireServer is passing v.Name, which is a string. In the second script (server) OnServerEvent handler, data corresponds to v.Name, but the script is attempting to index it (data[1]).
Attempting to index a string returns nil. I believe this is the problem.
Honeygold is correct.
The first script is a server script.