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

Why is part not being cloned and positioned? There is no error.

Asked by 4 years ago
Edited 4 years ago

Hi there, I am creating a Jerry can in Roblox Studio. I am trying to add a feature where you can pour the fuel in the Jerry can, as inspired from Neighborhood War (https://www.roblox.com/games/2039118386/Neighborhood-war-ALPHA-Read-Description)

When you click with the tool, particles come out of the can. This works fine. But, I also want parts to come out of the Jerry can. To achieve this, I am trying to clone a part in the Workspace and position it near the Jerry can when it is enabled. It is not working and there is no error message in the output.

Script:

while true do -- Loop
    if script.Parent.Particle.ParticleEmitter.Enabled == true then --Checks whether particles are enabled
        local clone = game.Workspace:FindFirstChild("GasolineDrop"):Clone() --Clones part
        local pos = script.Parent.Particle.Position
        clone.Position = Vector3.new(pos.X, pos.Y + 1, pos.Z) --Positions part
    end -- Concludes 'if' statement
    wait(0.25) -- Interval between each drop of fuel
end --Concludes loop

Thankyou for any support.

0
I tried CFrame already but it said the output said was a bad argument and to use Vector3 blocky010101 23 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

One obvious omission is that the clone is not getting parented to anything. You need to set clone.Parent to something in the Workspace (or game.Workspace itself). When you Clone() an instance, the Parent property of the original instance is not copied, the clone always has Parent of nil and you need to explicitly set it.

The other thing that could be a problem is if "Particle" is an Attachment rather than a Part. If so, you want to set the Position of your clone to Particle.WorldPosition, not Particle.Position, because the latter is a part-relative offset.

If this is not the case, maybe show us what the structure is so we can better assist.

0
Particle is the name of the part whose child is the ParticleEmitter. blocky010101 23 — 4y
0
Thank you! blocky010101 23 — 4y
Ad

Answer this question