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

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

Asked by
Prioxis 673 Moderation Voter
10 years ago

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

Log in to vote
4
Answered by
Hybric 271 Moderation Voter
10 years ago
game.Lighting["CHANGE THIS TO TOOL NAME"]:Clone().Parent = game.Players.LocalPlayer.Backpack
0
Wow i didnt notice that answer but our answer is exacly the same, Nice job Duckwit, Although i don't appreciate the -1 ): Hybric 271 — 10y
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 ;) duckwit 1404 — 10y
0
You thumbed me down ): Hybric 271 — 10y
Ad
Log in to vote
1
Answered by
duckwit 1404 Moderation Voter
10 years ago

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!

Answer this question