What do you want to achieve? Keep it simple and clear!
Topic
What is the issue? Include screenshots / videos if possible!
Topic
What solutions have you tried so far? Did you look for solutions on the Developer Hub? I looked through few topics, but found nothing good
Code:
while true do
print("Test")
local random = Random.new()
local randomTrajX = random:NextNumber(64, -64)
local randomTrajZ = random:NextNumber(64, -64)
local part = Instance.new("Part")
part.Name = "EndPoint"
part.Anchored = true
part.Transparency = 1
part.Position = Vector3.new(randomTrajX, 24, randomTrajZ)
part.CanCollide = false
part.Parent = script.Parent
local attachment = Instance.new("Attachment")
attachment.Parent = part
attachment.Name = "Attachment1"
script.Parent.AlignPosition.Attachment1 = attachment
if (script.Parent.Attachment0.Position - attachment.Position).Magnitude < 0.01 then
part:Destroy()
end
task.wait(0.1)
end
It just doesn’t create anything(OLD)
Currently can’t detect align position end
Are you sure? There are some errors, did you specify the parent correctly? Script works? if (script.Parent.Attachment0.Position - attachment.Position).Magnitude < 0.01 then won’t interfere?
Yeah i just realised that was problem. It destroyed part instantly. Now it correctly works. Though i need to do it somehow with local script, but i think that already for different topic.
Nah it just run infinitely, these parts are bad for performance. It should destroy after. While i was looking for script to wait for align position completion only what i found was loop with magnitude(i use same, but for me it just skips that if and runs code again. Maybe coroutine could help?).
Magnitude 0.01 is possible only if the positions are equal. But even after that, your loop will continue, you need to do some kind of check and enter break there to stop spawning.
Example:
if (script.Parent.Attachment0.Position - attachment.Position).Magnitude<1 then
part:Destroy()
break
end
Maybe better calculating exact time for part finish align position and then use it in task.wait? ((script.Parent.Position - script.Parent.EndPoint.Position).Magnitude/Velocity)
This is just animation for Photons(They are first currency in my incremental game(i’m making something inspired by Grass Cutting Incremental)). They will light up territory(game goal is to make everything bright in world of darkness) and fly by random trajectory. They have an end part, where they should finish align position, before running next one.I randomize trajectory(or position for end part) and then photon fly to endPos via alignPosition
Wait i have an idea. How could i set position of align position in OneAttachment mode? As i understood it should just move part to position, so i don’t really need to destroy any parts