Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a System That Makes a Player Able To Give Another Player a Tool Without dropping it?

Asked by 4 years ago

I Have Been Working On A Project And I Cant Find How I Would Be Able To Create a System Where A player can give another player a tool

2 answers

Log in to vote
0
Answered by 4 years ago

You can simply switch the Parent of the tool like this

local Tool = script.Parent
Tool.Parent = -- Refer to the other player here

Here is an example using that line

local Player = game.Players.LocalPlayer
local Tool = script.Parent
local Mouse = Player:GetMouse()

Mouse.Button1Down:Connect(function()
    local Target = Mouse.Target

    if Target:IsA("BasePart") and Target.Parent.Humanoid then
        Tool.Parent = Target
    end
end)
Ad
Log in to vote
0
Answered by 4 years ago

Take the tool and parent it to the other player.

Whenever a player has a tool equipped, it's found in their Character, which is how I tell what tool a player is currently using.

local tool = player1.Character.(the tool's name)
tool.Parent = player2.Character
0
Alternatively, you could parent it to player2's Backpack if you want it in their inventory rather than it to be equipped virushunter9 943 — 4y
0
Yeah, I just assumed the questioner wanted player2 to immediately gain it. But if that's what they're going for they can do that ye User#28017 0 — 4y

Answer this question