Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

I tried CFrame already but it said the output said was a bad argument and to use Vector3

1 answer

✓ Accepted answer

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.

2 comments

0

Particle is the name of the part whose child is the ParticleEmitter.

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.