I want to make a custom class gui. In this gui, I wan to be able to select a weapon and be able to remove it from backpack it when I click on a text button (text will say Remove). How would I retrieve the weapon from the lighting WHEN I CLICK A TEXT BUTTON AND THEN REMOVE IT ( rmove as in like to remove it from backpack.)WHEN PRESSING ANOTHER TEXT BUTTON???? The weapons are tools and I know i have to have tools in lighting. If answered I will be very grateful.
Getting Weapons from lighting?
3 answers
You should not be storing your weapons in the lighting see Replicated Storage
You should just be able to clone the tool Click here
You can delete the tool using this method Click here
Well firstly, I couldn't exactly understand what you were trying to ask here due to the grammar used in the post, but I may have a rough idea. Since you did not post a script of you attempting I'm not going to make the script for you, but I will tell you how it works.
Assuming you have the Gui already made for the guns what you want to do is check that the gun/weapon is in the lighting using an if statement, then you want to clone it and parent it to the player's backpack (hopefully you know how to find the player) Then once you have that done to remove the gun/weapon all you have to do is use an if statement to check if the gun is in that person's backpack and simply use Player.Backpack.Weapon:Destroy()
If you do not know how to do some of these things I recommend looking on the wiki (http://wiki.roblox.com)
Some Wiki stuff:
First of all; you shouldn't use Lighting for storing objects. You should use ReplicatedStorage or ServerStorage (if you're using a LocalScript, ReplicatedStorage).
Your question isn't very clear (spend more time editing, and no need to yell), but as I understand it two things have to happen:
- A way to give specific tools to player
- A way to clear out every tool that was given
Here's one option:
local player = game.Players.LocalPlayer
local backpack = player:WaitForChild("Backpack")
local tools = {}
-- A list of all the tools this player has been given
function giveTool( name )
-- Looks in game.ReplicatedStorage.Tools for something
-- named "name" and gives to the local player
local tool = game.ReplicatedStorage.Tools[ name ]:Clone()
-- A copy of it
tool.Parent = backpack -- Put it in their backpack
table.insert(tools, tool)
end
We are keeping track of tools so that we can make the clear function very easily:
function clearGivenTools()
for _, tool in pairs(tools) do
tool:Destroy()
end
tools = {}
end
Now you just have call these functions on buttons.
To change to a "class" (a group of tools) you would first clear and then add several tools:
function changeToMedic()
clearGivenTools()
giveTool( "Syringe Gun" )
giveTool( "Ubersaw" )
end
function changeToSpy()
clearGivenTools()
giveTool( "Cloak and Dagger" )
giveTool( "Butterfly Knife" )
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I'm glad I spent so much time on an answer that would make sense to him and some guy makes an answer in 3 lines and it's accepted, but mk, as long as he understands xD