Hand-to gui not working

Hello, I’m trying to make a hand-to GUI for my game and for some reason it’s not working. So I was just wondering if someone could review my code and see if I missed anything or something. There are no errors, it’s just not sending the tool to the other player. It might have something to do with the player variables because when you send a tool it moves the tool to the senders backpack instead of the receiver’s backpack. Here is my local script inside the button:

script.Parent.MouseButton1Click:Connect(function()
	local name = script.Parent.Parent.TextBox.Text
local from = game.Players.LocalPlayer
for i,v in pairs(game.Players:GetPlayers()) do
	local name2 = string.lower(v.Name)
		if string.sub(name2, 1, string.len(name2)) == name2 then
			local player = v
			game.ReplicatedStorage.sendTool:FireServer(from,player)
			wait(.1)
			script.Parent.Parent.TextBox.Text = ""
		else
			script.Parent.Parent.TextBox.Text = "Failed"
			wait(.5)
			script.Parent.Parent.TextBox.Text = ""
		end
		end
		end)

And here is the server script inside server script service:

game.ReplicatedStorage.sendTool.OnServerEvent:Connect(function(from, to)
	local tool = from.Character:FindFirstChildOfClass("Tool")
	if tool then
		print(to)
		local clone = tool:Clone()
		clone.Parent = to.Backpack
		
		tool:Destroy()
			local gui2 = game.Players[from.Name].PlayerGui.HandtoGUi.Gui2
			local gui1 = game.Players[from.Name].PlayerGui.HandtoGUi.Gui1
			gui2:TweenPosition(UDim2.new(0.175, 0,0.153, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, .5)
			wait(.5)
			gui2.Visible = false
			gui2.Position = UDim2.new(0.825, 0,0.153, 0)
			gui1.TextButton.Script.Disabled = true 
			wait(.2)
			gui1.TextButton.Script.Disabled = false 
			

	end
	
end)

Thank you in advance :slight_smile: .

When you use “:FireServer”, the function will automatically include the sender. sendTool:FireServer(from,player) actually sends (LocalPlayer, from, player).

In order to fix your code, just change the event to sendTool:FireServer(player).

What do you mean by hand-to? Could you elaborate.

He means giving a gear, commonly used in cafes.

Yes, that what I mean. It’s a GUI that you can type a player’s username in while equipping a tool, and it will send the tool to that player.

Good fix. But it still seems to not be working.

Like @apo_tle said, you don’t need to add the from, because it actually sends the player by itself, so on the client remove the from, but on the server you still have to retrieve it, have a nice day :smiley:

This is what I did:

Server:

game.ReplicatedStorage.sendTool.OnServerEvent:Connect(function(from, to)

Local:

game.ReplicatedStorage.sendTool:FireServer(player)

And it still doesn’t work. Am I missing something?

1 Like

I think you forgot to introduce the 2nd argument? In the local event fire it seems to be only 1 argument which is the player, equivalent to from.

I fooled around with it and ended up fixing it. Thank you to everyone that helped:
@apo_tle
@DaffyDavinko
@PaintDevs
@Socks347

1 Like