-
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 -
What is the issue? Include screenshots / videos if possible!
Exactly endPoint never gets destroyed and clones forever and forever - 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%)