Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

BLock moving stop location?

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

1 answer

✓ Accepted answer

I quite don't understand what you want to accomplish here.. So you want it so that when the part is placed, it will stop, move, and rotate at a certain position but not a position that is taken?

3 comments

0

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

0

Try using magnitude of target position and the current position of the object thats what I do in that type of situation

0

And how exactly is that done the roblox wiki explaination confused me?

This discussion is preserved as it was. New answers, comments, and votes are closed.