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

How do you clone something from the lighting to the players backpack?

I'm trying to design a inventory system to where when I click the button it'll give me a item and if I click it again it'll delete the item from their inventory...

2 answers

game.Lighting["CHANGE THIS TO TOOL NAME"]:Clone().Parent = game.Players.LocalPlayer.Backpack

3 comments

0

Wow i didnt notice that answer but our answer is exacly the same, Nice job Duckwit, Although i don't appreciate the -1 ):

0

Thanks! I don't think our answers are exactly the same, you haven't quite fully answered his question - sorry but that's how the system works! Well done though ;)

0

You thumbed me down ):

In short, you can clone an item from the Lighting into the Player's backpack like-so:

game.Lighting["ThingThatYouWantToClone"]:clone().Parent = player.Backpack

If you handle the item cloning in a LocalScript then you can reference the player using game.Players.LocalPlayer.

You can remove the item using the destroy() method:

player.Backpack.["ThingThatYouWantToDestroy"]:destroy()

You need to be more specific when you say "Click a Button" because there are few different mediums for button clicks in Roblox! For example, you could mean clicking a Part in the workspace, a GUI object, a SurfaceGUI, or even a button on your keyboard! For Part buttons, look at ClickDetector:

http://wiki.roblox.com/index.php?title=Clickdetector

For GUIs and SurfaceGUIs, look at the ImageButton and TextButton objects:

http://wiki.roblox.com/index.php?title=Guibutton

For keys on your keyboard look at the GetMouse() method and the KeyDown event:

http://wiki.roblox.com/index.php?title=GetMouse_(Method) http://wiki.roblox.com/index.php?title=KeyDown_(Event)

Also, it is probably better to use either ServerStorage or ReplicatedStorage (rather than Lighting) to store Instances.

Hope that helps!

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