So I have this script inside of StarterGui and i want it to make the weapon go in your backpack when you click the equip button. When you click it you do get the weapon, but when you die you lose it. Why is this and could anyone help me how to make it so that the weapon stays in your backpack even when you die?
--Note: in the script only the lines where it clones the weapon are really important I think.
script.Parent.MouseButton1Click:connect(function() if script.Parent.Parent.Parent.Parent.Parent.Parent.Backpack.Primary.Value then script.Parent.Parent.Parent.Parent.Parent.Parent.Backpack.Primary.Value = false local CloneGalil = game.ServerStorage["Galil AR"]:clone() CloneGalil.Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Backpack script.Parent.Parent.Parent.Dummy.Primary.Weapon.Weapon.Visible = true script.Parent.Text = "Weapon Equipped" wait(1) script.Parent.Text = "Equip" script.Parent.Visible = false else script.Parent.BackgroundColor3 = Color3.new(1,0,0) script.Parent.Parent.Parent.Parent.PrimaryAlreadyEquipped.Visible = true wait(1) script.Parent.BackgroundColor3 = Color3.new(0,1,0) script.Parent.Parent.Parent.Parent.PrimaryAlreadyEquipped.Visible = false script.Parent.Text = "Equip" script.Parent.Visible = false end end)
I would like to re-script your entire code, but that wouldn't be a good answer. Why? Because you wouldn't learn a single thing from copying and pasting.
So, I am going to give you a tip. It will be your job to apply it to your Script. Every Player has 4 children: "Backpack", "StarterGear", "PlayerGui" and "PlayerScripts".
Notice the StarterGear?
Here is what the Wiki says about it: StarterGear is a container that is automatically inserted into each Player when the player joins the game. If a game allows gear, all of a player's appropriate gear will be inserted in to StarterGear when the player joins the game. Whenever the player's Character spawns, all of the contents of that player's StarterGear will get copied into the player's Backpack.
All you need to do is copy the Tools to someone's StarterGear.
However, there is one problem!
If you copy Tools to a Player's StarterGear for the first time, you won't see it inside the Player's Backpack. To fix this, simply create another line of Code which will copy the Tool to the Player's Backpack.
So, in short:
Copy the Tool he/she has chosen to the Player's StarterGear and Backpack.
Let me know if you have any questions.