EndPoint Parts aren't getting destroyed properly

  1. What do you want to achieve? Keep it simple and clear!
    So i have an part for endPoint of align Position and it should destroy after align position is finished. Though as i know there is no proper detects of align position end
  2. What is the issue? Include screenshots / videos if possible!
    Exactly endPoint never gets destroyed and clones forever and forever
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? I looked tons of topics about align position end detect, but nothing would help

Code:


function create()
	local random = Random.new()
	local randomTrajX = random:NextNumber(100, -100)
	local randomTrajZ = random:NextNumber(100, -100)
	local randomTrajY = random:NextNumber(100, 20)
	local part = Instance.new("Part")
	part.Name = "EndPoint"
	part.Anchored = true
	part.Transparency = 1
	part.Position = Vector3.new(randomTrajX, randomTrajY, randomTrajZ)
	part.CanCollide = false
	part.Parent = script.Parent
	local attachment = Instance.new("Attachment")
	attachment.Parent = part
	attachment.Name = "Attachment1"
	script.Parent.AlignPosition.Attachment1 = attachment
end

while true do
	create()
	local delay = (script.Parent.Position - script.Parent.EndPoint.Position).Magnitude/script.Parent.AlignPosition.MaxVelocity
	if (script.Parent.Position - script.Parent.EndPoint.Position).Magnitude < 1 then
		script.Parent.EndPoint:Destroy()
		break
	end
	print(delay)
	task.wait(delay)
end

Also problem is caused by delay. I can’t just wait until align position finish so i use a while loop. I tryed doing math calculated delay(like it calculates velocity and distance, though it works in like 20%)

Bumping that dead topic (30 lettersssssssss)

Is there a reason you are creating a part for the end point of your AlignPosition? You could set the attachment the alignment mode to be one attachment, and then just set the position of the AlignPosition directly instead of creating a secondary part just to make the primary part move.

image

I can’t imagine for a reason that you would need the end part to still exist considering you are trying to destroy it

Oh… I never know about that oneAttachment mode. Let me try…

That works perfectly as i expected. Thanks!

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