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

How to make a brick that when touched goes into your inventory and appears on your characters back?

Asked by 9 years ago

I want to make a cash bag that you can pick up and goes on your back, pretty simple right? So far the bag is a tool so it goes in your inventory but i also want it to appear on your back and stay there as you walk around.

This is my attempt

function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
script.Parent:Clone().Parent = h


end
script.Parent.Touched:connect(onTouched)

The result is that it goes in your inventory and clones it but it keeps on cloning infinitly and the bags go flying everywhere

Please help i just want it so you can pick it up and it shows on you back as you walk around

0
I wouldn't say that's simple. HungryJaffer 1246 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

I believe you may be able to do this using the GripPos property of tool with little to no coding. This sets an offset for the tool's handle. If you play about with it in testing, you should get some good numbers. The only problem is that the character will have its hand out while the tool is equipped.

If you want the character to be able to equip another tool while holding that one, you can do that by placing the bag in the character directly any time another tool is selected, like so:

-- In a local script inside any tool you want to equip simultaneously.
local Player = game.Players.LocalPlayer
local Backpack = Player.Backpack
script.Parent.Equipped:connect(function ()
    if Backpack:FindFirstChild("NameOfTool") then
        Backpack.NameOfTool.Parent = Player.Character
    end
end)

Also, if you don't want the player to be able to unequip the tool, you could do something very similar to above:

-- In a local script inside any tool you don't want unequipped.
local Player = game.Players.LocalPlayer
local Backpack = Player.Backpack
script.Parent.Unequipped:connect(function ()
    wait()
    script.Parent.Parent = Player.Character
end)
Ad

Answer this question