Creating a node based track system for use in Train Sims. [Hit a road block]

Hey fellow developers,

I’m currently trying to develop a system that’ll make life easier when making Train Simulators, by that I mean I’m creating a node based tracking system that makes “bogies” follow a single rail. I’ve made it so that you can set the distance between bogies using a NumberValue too. Everything works well so far, but I seem to have run into a problem; I don’t know what is happening but randomly the weld part (The Middle Part) just disappears, completely gone from the workspace. I’ve come a cross this before and I simply check to see if the CFrame wasn’t nil, but that has not worked in this situations, and I’m just stumped.

I’ve been at this since April and recently started again due to some advice from @BanTech on another thread. So help with other aspects of the project would be greatly appreciated.

This is the only section that interacts with that weld part.

RS.Heartbeat:connect(function()
	CentralPoint = (Bogie1.Position + Bogie2.Position) / 2
	Root:SetNetworkOwner(nil)
	local newRootCFrame = CFrame.new(CentralPoint, Bogie1.Position)
	print("============================")
	print(newRootCFrame.LookVector)
	print(newRootCFrame.RightVector)
	print(newRootCFrame.UpVector)
	print(newRootCFrame.Position)
	print("============================")
	if newRootCFrame.Position == newRootCFrame.Position then
		Root.CFrame = newRootCFrame
	else
		print("lol")
	end
end)

Thank you for your time.

2 Likes

What’s the Anchored and CanCollide setting for it?

Can you confirm your bogies don’t do anything super weird? How is their position being set.

I can’t really imagine why it would disappear, unless you got below the minimum height in the workspace.

Every part by default is un-anchored with can-collide on, until the game starts, can-collide is turned off

When you divide the entire vector by two, your also dividing the y value. Essentially splitting the y value in half everytime

If you wanna see all of the script ill just post it all

if both Y values are the same e.g. 1, doing (1 + 1) / 2 is still one, so it should be a problem

1 Like

You may get along better with them anchored, given you’re placing them each frame anyway. They shouldn’t need to be unanchored really. It might cause weird issues of them flying off for whatever reason Roblox physics chooses.

I’m using BodyMovers with the 2 bogies. I’m only able to anchor the RootPart

Okay I understand, the RootPart still works as intended when its anchored