So i try to make a part that spawns when i click on a gui and then it rotates and moves. Everything is working but i wonder how i can do so it stops move and rotate at a specific position like when it have reached another parts position because its very hard to find the right place with the "For Loop"
My Code looks like this for the moment btw this script is inside PlayerGui.ScreenGui.TextButton
function onClicked()
x = Instance.new("Part", game.Workspace)
x.Size = Vector3.new(10,10,10)
x.Position = Vector3.new(5,5,5)
x.BrickColor = BrickColor.new("Bright blue")
x.Transparency = "0.1"
x.Anchored = true
x.TopSurface = "Smooth"
x.BottomSurface = "Smooth"
for rm = 1,380 do
x.CFrame = x.CFrame *CFrame.Angles(0.1,0.1,0.1)
x.Position = x.Position +Vector3.new(0,0,0.1)
wait()
end
x:remove()
wait()
end
script.Parent.MouseButton1Click:connect(onClicked)
the most important to part to look at i think would be.
for rm = 1,380 do
x.CFrame = x.CFrame *CFrame.Angles(0.1,0.1,0.1)
x.Position = x.Position +Vector3.new(0,0,0.1)
wait()
end
Btw Sorry for my grammar and English

3 comments
I mean i have this script that moves with +Vector3.new and it rotates with *CFrame.Angles but i want to specify where it would stop whenever it reaches a specific part(brick) like a finish line
Try using magnitude of target position and the current position of the object thats what I do in that type of situation
And how exactly is that done the roblox wiki explaination confused me?