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

How do I insert an item into the players backpack?

Alright, so I need to insert a tool into a players backpack when a tool they are holding touches a part. How do I do so?

Heres the script I tried to make:

local tool = script.Parent

local Handle = tool.Handle

Handle.Touched:connect(function(hit)

end)

if debounce == true then

return

end

debounce = true

if Handle.Touched:connect(function(hit) Name = "123456" then clone.game.ServerStorage.cookedbred = plr.Backpack

end

PLEASE HELP!!! NEED THIS SOON!!!

1 comment

0

I edited the answer, its been tested in studio this time

1 answer

✓ Accepted answer

Edit: I have no idea what I was thinking before because that code had a lot of errors to fix. The correct script is located below:

local tool = script.Parent
local Handle = tool.Handle
local debounce = false

Handle.Touched:connect(function(hit)
	if debounce == true then
		return
	end
	debounce = true
	if hit.Name == "123456" then
		local clone = game.ServerStorage.cookedbred:Clone()
		clone.Parent = game.Players[Handle.Parent.Parent.Name].Backpack
	end
	wait(1)
	debounce = false
end)

Sorry about the last answer. Please accept this one if it helped and don't hesitate to ask questions.

2 comments

0

ok

0

22:44:57.984 - Players.DannyDxmpster.Backpack.uncooked-bred.Script:17: attempt to index global 'hit' (a nil value) unfortunately that error happened, idk what it is

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