#bullet still appear in the previous gun that uneqquipped?? help me please:)

1 messages · Page 1 of 1 (latest)

hasty cloak
#

i tried to make a working gun now the problem is when i equip a gun its work! PROBLEM: BUT when i uneqquiped then equip it again tryna shoot the bullet appear but there is ANOTHER bullet also appear at the previous location before i uneqquiped the gun if you didnt understand i put a video in this post you can take a look you can help me by giving a code to fix it or give a link with same problem and solved
this bug maybe bc i didnt write if unequiped it disable the script or another thing i forgot to write.
so yeah please help me:(

#

local Deagle = script.Parent
local UserInputService = game:GetService("UserInputService")
local Debris = game:GetService("Debris")

local debounce = false
local cooldown = 1.0
local inputConnection -- store the connection so we can disconnect later

local function onInput(input, gameProcessed)
if gameProcessed or debounce then return end

if input.KeyCode == Enum.KeyCode.E then
    debounce = true

    -- 🔫 Create the bullet
    local bullet = Instance.new("Part")
    bullet.Name = "Bullet"
    bullet.Shape = Enum.PartType.Block
    bullet.Size = Vector3.new(0.4, 0.4, 0.4)
    bullet.BrickColor = BrickColor.new("New Yeller")
    bullet.Material = Enum.Material.Neon
    bullet.CanCollide = true
    bullet.Anchored = false
    bullet.CFrame = Deagle.CFrame
    bullet.Velocity = Deagle.CFrame.LookVector * 900
    bullet.Parent = workspace

    -- 💥 Damage logic
    bullet.Touched:Connect(function(hit)
        local humanoid = hit.Parent:FindFirstChild("Humanoid")
        if humanoid then
            humanoid:TakeDamage(25)
            bullet:Destroy()

            

        end
    end)

    Debris:AddItem(bullet, 2)

    task.delay(cooldown, function()
        debounce = false
    end)
end

end

-- 🔧 Handle Equipped
Deagle.Equipped:Connect(function()
inputConnection = UserInputService.InputBegan:Connect(onInput)
end)

-- 🧼 Handle Unequipped
Deagle.Unequipped:Connect(function()
if inputConnection then
inputConnection:Disconnect()
inputConnection = nil
end
end)

#

its the script i wrote i get some help from gpt too pls dont bully me, ALSO that file is not a virus it just a video

tight swallow
#

Was this all made by gpt?

#

Because it looks suspiciously like it was

hasty cloak
hasty cloak
tight swallow
#

without ai, I want you to try to do some sanity checks to see if the bullet is still in the workspace when unequipped