Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to make item drop go directly into the backpack?

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

You can use player.Backpack.

For instance,

local clone = bag:Clone()

clone.Parent + player.Backpack

2 comments

0

clone.Parent = player.Backpack

0

My mistake

This discussion is preserved as it was. New answers, comments, and votes are closed.