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

how to make item drop go directly into the backpack?

Asked by 3 years ago

So I have this code that when the dummy is killed as a chance to drop a item, but I couldn't figure out how to make it go directly into the players backpack, currently it just drops on the ground.

Script

local humanoid = script.Parent:FindFirstChild("Humanoid")
local rp = game:GetService("ReplicatedStorage")
local drop = rp.drop:FindFirstChild("Rusty Hammer")
local hr = script.Parent:FindFirstChild("HumanoidRootPart")

humanoid.Died:Connect(function()
    local dropChance = math.random(1, 4) 
    if dropChance == 1 then
        local clone = drop:Clone()
        clone.Parent = workspace
        local Handle = clone:FindFirstChild("Handle")
        if Handle then
            Handle.CFrame = hr.CFrame
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

You can use player.Backpack.

For instance,

local clone = bag:Clone()

clone.Parent + player.Backpack
0
clone.Parent = player.Backpack Ponytails2017 83 — 3y
0
My mistake Ponytails2017 83 — 3y
Ad

Answer this question