It’s not a complicated script…
script.Parent:GetPropertyChangedSignal("Orientation"):Connect(function()
script.Parent.Orientation = Vector3.new(0, script.Parent.Orientation.Y, script.Parent.Orientation.Z)
end)
It’s not a complicated script…
script.Parent:GetPropertyChangedSignal("Orientation"):Connect(function()
script.Parent.Orientation = Vector3.new(0, script.Parent.Orientation.Y, script.Parent.Orientation.Z)
end)
GetPropertyChangedSignal doesn’t fire on stuff changed by the engine. You would need to put it in a Heartbeat.
local Part = script.Parent
game:GetService("RunService").Heartbeat:Connect(function()
Part.Orientation = Vector3.new(0, Part.Orientation.Y, Part.Orientation.Z)
end)
The train doesn’t move now. It looks like it’s trying to get somewhere but is being put back to it’s original position.
Then you could try putting a -5 value in the LinearVelocity.
Didn’t change anything.
It does the same thing.
I mean a -5 Value in the Y position.
Well, it still does the same thing. I’ve tried -5 and -15.
Actually you can use AlignOrientation in One attachment mode and specify an Orientation using primary axis.
Is the train going to only go straight? If so just use a PrismaticConstraint.
If the train is supposed to turn corners then you are going to have issues with AlignOrientation not keeping it on the rails.
Or try Searching the forums.
I’ve helped a couple people on other posts using Constaints for trains.
Will it make the train turn only by Y and Z? How do I do that?
AlignOrientation will align by Axis meaning that you have to find out a right axis.
I want the train to turn on turns.
I’ve tried searching the forums, but I didn’t find anything helpful.
If you want AlignOrientation to only work on 2 axes then only put large Force values in those.
For example if you need no force on the Y axis then make the Force (100000,0,100000)
*** EDIT ***
Sorry, I was thinking of a BodyGyro.
There are a few different ways that AlignOrientation works, depending on if you have Mode (One or Two Attachments) and the 3 AlignOrientation properties checked off.
If you check the PrimaryAxisOnly property then another one pops up called AlignType.
It’s a whole lot of information to figure out. Here’s a Roblox example place that shows each way of setting the constraints up. They seem to have taken it down, but I managed to download it from the site.
New Body Movers, Physics, Constraints Example.rbxl (35.0 KB)
Play it in Test mode from Studio and you can see the way the properties are set up in each example.
Well, I’m used to working with BodyGyro and seeing this new AlignOrientation is very confusing for me…
I searched “keeping train on tracks”
What Method To Use When Trying To Make a Train Follow a Track - #27 by Scottifly
But BodyGyro worked the same way, you just put a 0 value in for the value that you want it to be able to spin on.
If the other ones don’t work, this one should work decently. Keep in mind that if the client pushes, it might look like it is moving, but on the server it is not.
Here’s my code,
local axisToLimt = {true, false, false}
script.Parent:FindFirstChildOfClass("AlignOrientation").Parent.Changed:Connect(function()
if game:GetService("ServerStorage"):FindFirstChildOfClass("AlignOrientation") then
game:GetService("ServerStorage"):FindFirstChildOfClass("AlignOrientation").Parent = script.Parent
end
end)
script.Parent:GetPropertyChangedSignal("Orientation"):Connect(function()
if axisToLimt[1] == true then
script.Parent:FindFirstChildOfClass("AlignOrientation").Parent = game:GetService("ServerStorage")
script.Parent.Orientation = Vector3.new(0, script.Parent.Orientation.Y, script.Parent.Orientation.Z)
elseif axisToLimt[2] == true then
script.Parent:FindFirstChildOfClass("AlignOrientation").Parent = game:GetService("ServerStorage")
script.Parent.Orientation = Vector3.new(script.Parent.Orientation.X, 0, script.Parent.Orientation.Z)
elseif axisToLimt[3] == true then
script.Parent:FindFirstChildOfClass("AlignOrientation").Parent = game:GetService("ServerStorage")
script.Parent.Orientation = Vector3.new(script.Parent.Orientation.X, script.Parent.Orientation.Y, 0)
end
end)
a bit messy because I didn’t refine it, but I hope it helps!
I’ve setup the AlignOrientation the same way as BodyGyro and for my surprise it doesn’t derail anymore! It still shakes a bit, but that shake is okay. Thank you!
Sorry for bumping a dead thread, but do you still have the place file? Clicking the link seems to lead to an ‘oops this page doesn’t exist’
This post a few down from the first one I linked has the models I was sharing:
What Method To Use When Trying To Make a Train Follow a Track - #31 by Deadstatic77