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 .