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

I Like Trains... Can you help me with my train?

Hey guys, Happy Friday!

I might figure this out tonight, but if anyone could help point me in the right direction, that'd be nice cause Im kinda lost.

I'm making a script on moving this train, but the train is very slow so I want to increase the speed, Rotate the train to return, and change the direction of the vehicle.

I imagine it will take a lot of looping, but Im unsure on how to get loops to run efficiently so I started here:

parts=script.parent.Train:GetChildren()

while true do
wait()
for i=1,#parts do
	parts[i].CFrame=CFrame.new(0,0,.1)*parts[i].CFrame
end
end

I suppose I could have two extra scripts, one for the return CFraming, the other to rotate the vehicle after a certain period of time and toggle disable/enable the other two scripts ...

Just doesn't seem like that'd help my game flow at optimal levels.

Any input is appreciated, Take it easy guys!

-G7

1 answer

✓ Accepted answer

Because you're looping it using the for loop, it's moving each part 1 by one.

I recommend that you set the primary part's CFrame using

train = script.Parent.Train

Go on the ROBLOX wiki and search the topic of setting primary part CFrame because I think I may have used the inbuilt function incorrectly, but this should move the train all at once if you do it correctly.

train:SetPrimaryPartCFrame() = CFrame.new(0,0,0)

1 comment

0

Oh thanks, I will try that! I always have a problem setting the primary part.. it tends to throw errors at me. May also use repeat/until loop

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