When you touch this part twice you get the weapons twice so

Assault will be in your backpack 2 times anyway to fix that problem?

function onTouched(part)
        p = game.Players:playerFromCharacter(part.Parent)
        if p == nil then return end
    local gun1 = game.Lighting.Assault:clone() 
        if p.Backpack:findFirstChild(gun1.Name) ~= nil then return end
        gun1.Parent = p.Backpack
   local  gun2 = game.Lighting.Pistol:clone() 
        if p.Backpack:findFirstChild(gun2.Name) ~= nil then return end
        gun2.Parent = p.Backpack
   local  gun3 = game.Lighting.SMG:clone() 
        if p.Backpack:findFirstChild(gun3.Name) ~= nil then return end
        gun3.Parent = p.Backpack
   local gun4 = game.Lighting.Shotgun:clone() 
        if p.Backpack:findFirstChild(gun4.Name) ~= nil then return end
        gun4.Parent = p.Backpack
   local gun5 = game.Lighting.Sniper:clone() 
        if p.Backpack:findFirstChild(gun5.Name) ~= nil then return end
        gun5.Parent = p.Backpack
end -- We only need one end statement, which closes the "onTouched" function. All the other if statements above have their end statement, so we don't need any additional ones.

script.Parent.Touched:connect(onTouched)

3 comments

0

Use the second solution I gave here: https://scriptinghelpers.org/questions/29496/expect-near-end-explanation-help#32915 - under the "Better solution" title.

1

debounce is what your looking for

0

ScriptGuider the script doesnt want to work for me.. i Have tried it but it doesnt want to work the other script works just keeps giving the weapons