Trouble with cloning and teleporting parts

Hello!

I am currently developing a game and I’m creating a system where cloned parts drop onto the ground automatically, sort of like an automatic dropper in a tycoon game.

The issue is that the parts are just not appearing in the workspace, even though my output log says it does.

For reference, here is my code:

local replicatedstorage = game.ReplicatedStorage
local base = replicatedstorage.DropPart

while true do
	local part = base:Clone()
	part.Parent = game.Workspace
	part.Position = game.Workspace.DropPoint.Position
	print("Part spawned.")
	wait(2.5)
end

I’ve tried looking everywhere, but I can’t find a good working solution.

Can someone help? Thanks!

Is the DropPoint part unanchored and with CanCollide unchecked like below?
image

1 Like

The DropPoint part is anchored and CanCollide is unchecked. Should I uncheck them?

The part should be anchored and CanCollide should be false. You could try printing the position of both the part you have cloned and the DropPoint part AFTER setting the position of the part and seeing how they compare? This could give you a clue as to what the issue is.

No need. The problem could be that if DropPart has CanCollide unchecked, it could be showing up in the workspace, but no clipping ground and disappearing in void

1 Like

I just tried this and for some reason the output says that the cloned part’s start position is exactly the same as the DropPoint’s position. It’s like the cloned part randomly disappears or doesn’t exist, even though the output says otherwise.

Try checking in explorer to see if the part instance disappear. Since both parts are in the exactly same position, DropPart could not be falling at all.

As @MrChrys_keke mentioned, you can try making sure that CanCollide on the DropPart is set to true. If the DropPoint is the same size and shape as your DropPart and is not transparent, then it is possible the part is getting set to the correct position but is being masked by your DropPoint.
Or it could be that your DropPart has the transparency set to 1 making it so that you cannot see it when it is parented.

I would recommend using explorer and the move tool to see where exactly the part gets to when it is cloned. The move tool’s arrows will allow you to easily identify where the part is in the workspace, so you can see where the part goes.

After a quick look, it appears that the script is actually not even putting the part in the workspace, let alone creating it whatsoever. Very odd.

Is the code you have provided the only code in that script?

Yes, the code that I provided is in fact the only code.

Very weird… Are there no errors in the console and are you 100% sure the part attempting to be cloned from ReplicatedStorage exists in ReplicatedStorage where the script is expecting it to be?

There are no errors in the console and the part is inside of ReplicatedStorage.

try giving the part a name while cloning it?

Update: I solved the problem myself. For some reason, they weren’t spawning since the Y-level of the parts spawning was too low.

2 Likes

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