Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

BLock moving stop location?

Asked by
Kryddan 261 Moderation Voter
9 years ago

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

Log in to vote
0
Answered by 9 years ago

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?

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 Kryddan 261 — 9y
0
Try using magnitude of target position and the current position of the object thats what I do in that type of situation Voltoxus 248 — 9y
0
And how exactly is that done the roblox wiki explaination confused me? Kryddan 261 — 9y
Ad

Answer this question