Instance:Clone() is cloning two times

We can’t help you if the video doesn’t load.

1 Like

Can you show us where you clone the fallen bullet shells. Cant really do much without it. Also I think this may be a Scripting Support category.

1 Like

We need to see your code pls also can you block it ````lua The video doesn’t rlly help

2 Likes

local flashLight = script.Parent.Barrel.Attachment.FlashFX
local flashParticle = script.Parent.Barrel.Attachment[“FlashFX[Flash]”]
local Smoke = script.Parent.Barrel.Attachment.Smoke
local casingattachment = script.Parent.Slide.Attachment

local casing = game.ReplicatedStorage.MP5.Casing:Clone()
casing.Position = casingattachment.WorldPosition
casing.Parent = workspace.Stuffz
casing.Sound:Play()

flashLight.Enabled = true
flashParticle.Enabled = true
Smoke.Enabled = true

local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Velocity = casingattachment.CFrame.lookVector + Vector3.new(-2,2,0)
BodyVelocity.Parent = casing
game:GetService("Debris"):AddItem(BodyVelocity, 0.2)
game:GetService("Debris"):AddItem(casing,1.5)
wait(0.1)
flashLight.Enabled = false
flashParticle.Enabled = false
Smoke.Enabled = false

To me that looks fine. Can you show the part of the script that is firing the weapon?

1 Like

its a function in a module so it calls a function in the Server Script
gunmodule.ParticlesAndCasing()

I will try to help you this clones the casing model stored under MP5 in the ReplicatedStorage.

However, if the casing is meant to be cloned only once and used repeatedly, it might make sense to move the cloning operation outside of a function that gets called multiple times.


local casingOriginal = game.ReplicatedStorage.MP5.Casing
--... other local variables ...

local function fireGun()
    local casing = casingOriginal:Clone()
    casing.Position = casingattachment.WorldPosition
    casing.Parent = workspace.Stuffz
    casing.Sound:Play()

    flashLight.Enabled = true
    flashParticle.Enabled = true
    Smoke.Enabled = true

    local BodyVelocity = Instance.new("BodyVelocity")
    BodyVelocity.Velocity = casingattachment.CFrame.lookVector + Vector3.new(-2,2,0)
    BodyVelocity.Parent = casing
    game:GetService("Debris"):AddItem(BodyVelocity, 0.2)
    game:GetService("Debris"):AddItem(casing,1.5)
    wait(0.1)
    flashLight.Enabled = false
    flashParticle.Enabled = false
    Smoke.Enabled = false
end

1 Like

It is Still cloning the casing 2 times

You are most likely calling the function to create the casing twice. Try adding a print to see if it prints twice as well.

2 Likes

Yup you are right But ive looked through all my code like 5 times and i couldnt find anything

Nvm I fixed it i just had to put the function at the end of the Server Script
THANK YOU for everyone who tried to help!

1 Like

Bruh I was poopingL lolololuigjkk

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.