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

Putting an item into someone's backpack?

I want to put an item to someone's backpack everytime they come ingame I got a local script inside a HopperBin where the code is.At the end I've put this but didn't work..Any suggestions?

n.Parent = game.Players.PLAYERNAME.Backpack -- n is the HopperBin

1 comment

0

If Perci's answer doesn't work, make sure to put the whole script.

1 answer

In Lua, the dot (.) searches for an object or property by name.

This means that unless someone has the username "PLAYERNAME", your code won't work.


Since LocalScripts run on the client (that is, the Player's computer), we can use the LocalPlayer property of the Players service to access player that the script is running on.

n.Parent = game.Players.LocalPlayer.Backpack
--[[  There does not have to be a player named
	'LocalPlayer' because we are looking for a property,
	not a child, and that property name is valid. ]]--

1 comment

0

yeah but that is exactly what I want, to be in someone,s backpack by his name

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