I am making a cafe, and my hand-to system currently does not work at all. I can not figure out why, and as I am new to using remotes, I am lost.
game.ReplicatedStorage.handTo:WaitForChild("main").OnServerEvent:Connect(function(tool,target)
tool.Parent = target.Backpack
end)
Client(GUI):
function getPlayer(shortcut)
local player = nil
local g = game.Players:GetPlayers()
for i = 1, #g do
if string.lower(string.sub(g[i].Name, 1, string.len(shortcut))) == string.lower(shortcut) then
player = g[i]
break
end
end
return player
end
function CHECK_TOOL(character)
for _, v in pairs(character:GetChildren()) do
if v:IsA("Tool") then
game.ReplicatedStorage:WaitForChild("main"):FireServer()
else
script.Parent.Target.Text = "Please type a players name!"
wait(1)
script.Parent.Target.Text = ""
return true
end
end
end
local p = getPlayer(script.Parent.Target.Text)
local plr = script.Parent.Parent.Parent.Parent.Parent.Character
local trg = p
script.Parent.Target.FocusLost:Connect(function(plr,trg)
CHECK_TOOL(plr)
end)
Errors:
Thanks in advanced to anyone who took the time to read my post 
1 Like
A few things I found wrong in ur code (just a quick look)
script.Parent.Target.FocusLost:Connect(function(wasThisStopedBecauseThePlayerPressedEnter, otherCause) -- this function has two defoults arguments so u cant return plr and trg
And also when u are Firing Server u didnt pass any arguments, u should put ur tool in there… and when u are picking it up on the server ur first argument is a player and ur second is a tool
2 Likes
game.ReplicatedStorage.handTo:WaitForChild("main").OnServerEvent:Connect(function(player, tool)
tool.Parent = player.Backpack
end)
next in the local script, I wont include your string loop, because I have never worked with strings before but here u go:
function CHECK_TOOL(character)
for _, v in pairs(character:GetChildren()) do
if v:IsA("Tool") then
game.ReplicatedStorage:WaitForChild("main"):FireServer(v)
else
script.Parent.Target.Text = "Please type a players name!"
wait(1)
script.Parent.Target.Text = ""
return true -- U DONT HAVE TO RETURN SOMETHING IF U ARE NOT PICKING IT UP; WHEN U ARE CALLING IT
end
end
end
local p = getPlayer(script.Parent.Target.Text) -- IDK WHATS THIS
local plr = game.Players.LocalPlayer -- U ARE IN THE LOCAL SCRIPT
local trg = p
script.Parent.Target.FocusLost:Connect(function(Enter, otherCause)
CHECK_TOOL(plr.Character)
end)
Maybe I missed something, let me know