works sometimes but other times it doesnt
local gune = game.Lighting.Assault.Assaulta.Guna script.Parent.MouseButton1Click:connect(function() if game.Players.LocalPlayer.leaderstats.KOs.Value >= 0 then game.Players.LocalPlayer.Backpack.Guna:Destroy() game.Players.LocalPlayer.StarterGear.Guna:Destroy() local clone = gune:Clone() clone.Parent = game.Players.LocalPlayer.Backpack local clonea = gune:Clone() clonea.Parent = game.Players.LocalPlayer.StarterGear end end)
Your problem is you don't check to see if the gun ("Guna") exists before deleting it from the player's backpack or starter gear. The reason it works half of the time is due to the fact that it checks only the backpack to find the gun instead of the player itself. If a player has the gun equipped, then the gun will be relocated to their character model. Here's how you can fix the script:
local gune = game.Lighting.Assault.Assaulta.Guna local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() if player.leaderstats.KOs.Value >= 0 then if player.Backpack:FindFirstChild("Guna") then player.Backpack.Guna:Destroy() end if player.StarterGear:FindFirstChild("Guna") then player.StarterGear.Guna:Destroy() end local clone = gune:Clone() clone.Parent = game.Players.LocalPlayer.Backpack local clonea = gune:Clone() clonea.Parent = game.Players.LocalPlayer.StarterGear end end)