Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cloned part gets deleted a few seconds later, how do I make it stay? [SOLVED BY ME]

Asked by 4 years ago
Edited 4 years ago

Here is my code so far (This is some part of it that is cloning the model, but is actually 164 lines of code):

-- Since the chances are hit, we will make the gun.

                    -- We want the gun in an random location, so we choose a varible for that.
                    local offX = part.Position.X + math.random(part.Size.X/4, (part.Size.X/4)  + 5.5)
                    local offY = part.Position.Z + math.random(part.Size.Z/4, (part.Size.Z/4) + 5.5)

                    -- We set a primary part for the model.
                    local primaryPart = Instance.new("Part")
                    primaryPart.Parent = workspace.A
                    primaryPart.Position = Vector3.new(offX, 2.5, offY)
                    primaryPart.CanCollide = false
                    primaryPart.CastShadow = false
                    primaryPart.Transparency = 1

                    -- We clone a certain model.
                    local guns = workspace.__GUNS__:GetChildren()
                    local gunSelected = math.random(1, #guns)
                    local model = guns[gunSelected]:Clone()

                    model.Parent = workspace.A
                    model.PrimaryPart = primaryPart
                    model:SetPrimaryPartCFrame(CFrame.new(primaryPart.Position))
0
yay u solved it royaltoe 5144 — 4y

Answer this question