Part dissapearing

When i put the new object it remains like a ghost and then disspears or just dissapears…
I don’t know what i should do about this… is it maybe the order of the lines? like, i got thge last object then got the clone of the new object and put it in the same part then killed the current obj and let the new one stay and changed it position. i don’t see any problem in the code…

CategoryItem = game.ServerStorage.Items[CategoryName][itemName]:Clone()
		local lastObj = workspace[player.Name.."-ball"].Confetti
		CategoryItem.Parent = workspace[player.Name.."-ball"]
		CategoryItem.Name = "Confetti"
		CategoryItem.CanTouch = false
		CategoryItem.CanCollide = false
		CategoryItem.Transparency = 1
		while lastObj:GetAttribute("InUse") do
			wait(0.01)
		end
		lastObj:Destroy()
		CategoryItem.Position = CategoryItem.Parent.Position
1 Like

Well the first question is is it anchored? Because right now it will just fall through the map if not. That’s the only thing I can think of because the rest of the code looks fine to me.

Though instead of looping to see when the attribute changes you should consider using events.

https://developer.roblox.com/en-us/api-reference/function/Instance/GetAttributeChangedSignal

1 Like

Thanks for the advice, i didn’t think of that since i’m pretty stupid sometimes so i forgot that i can use functions inside functions. i’ll try to anchor them.

Edit: Yes, this was the problem, anchoring them. Thanks!

1 Like