Hello,
So I have been creating a tool, and I want to include a hand-to system. Basically, when a player presses H they enter ‘hand to’ mode, and as soon as they click on another player, it gives the tool to them. I am using a local script and Remote event to actually give the tool in a local script. So far I have tried moving the tool’s parent, cloning it to the other player and destroying the original, but nothing works. As soon as it gets to the Server Script it just immediately breaks. Trying a print()
statement in there works, but the actual hand to system does absolutely nothing.
-- LOCAL SCRIPT --
local handToMode = false
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local handToEvent = ReplicatedStorage:WaitForChild("HandToEvent")
mouse.KeyDown:connect(function(key)
if string.upper(key) == "H" then
handToMode = not handToMode
print(handToMode)
end
end)
mouse.Button1Down:Connect(function()
if handToMode == true then
local handedPlr = game.Players:GetPlayerFromCharacter(mouse.Target.Parent)
print(handedPlr)
print(handedPlr ~= nil)
if handedPlr ~= nil then
handToEvent:FireServer(player, handedPlr)
end
end
end)
-- SERVER SCRIPT --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local handToEvent = ReplicatedStorage:WaitForChild("HandToEvent")
local handToEvent = ReplicatedStorage:WaitForChild("NotifyEvent")
local function handItem(giver, receiver)
local tool = giver.Character:FindFirstChildWhichIsA("Tool")
tool:Clone().Parent = receiver
giver.Character.Humanoid:UnequipTools()
tool.Destroy()
end
handToEvent.OnServerEvent:Connect(handItem)
I don’t get any errors in the output or such, though. Person A just keeps the drink and Person B gets absolutely nothing.
Thanks in advance, B!