perhaps the primarypart
of the model has not been set?
Also if the primary part is not anchored/welded to the model or is non-collideable, it can fall through the map and also cause this issue.
`spawnTrain.OnServerEvent:Connect(function(player, trainName, siding, depot)
if trains[trainName] then
if siding then
if sidings[siding] and sidings[siding].SpawnBox then
local partsInBox = workspace:GetPartsInPart(sidings[siding].SpawnBox)
local sidingOccupied = false
for _, part in pairs(partsInBox) do
if part.Name == "FrontSensor" or part.Name == "RearSensor" then
sidingOccupied = true
end
end
if sidingOccupied == true then
spawnTrain:FireClient(player, true)
return
end
local clonedTrain = trains[trainName]:Clone()
local trainInfo = clonedTrain:FindFirstChild("TrainInfo")
if trainInfo then
trainInfo.StartTime.Value = tick()
trainInfo.Route.Value = "RO01"
if routesModule["RO01"] then
local position = table.find(routesModule["RO01"], siding)
if position then
trainInfo.NextStation.Value = routesModule["RO01"][position]
trainInfo.ScheduledTime.Value = (trainInfo.ScheduledTime.Value == 0 and trainInfo.StartTime.Value or trainInfo.ScheduledTime.Value) + routesModule["RO01-"][position]
if sidings[siding].Direction then
if sidings[siding].Direction.Value == "Northbound" then
if trainInfo.NextStation.Value == sidings[siding].Name then
trainInfo.Destination.Value = routesModule["RO01"][1]
else
trainInfo.Destination.Value = routesModule["RO01"][#routesModule["RO01"]]
end
elseif sidings[siding].Direction.Value == "Southbound" then
if trainInfo.NextStation.Value == sidings[siding].Name then
trainInfo.Destination.Value = routesModule["RO01"][1]
else
trainInfo.Destination.Value = routesModule["RO01"][#routesModule["RO01"]]
end
end
end
end
end
end
local randomNumber = math.random(1, 999)
clonedTrain.Name = "Train" .. randomNumber
if workspace.ActiveTrains:FindFirstChild(clonedTrain.Name) then
while workspace.ActiveTrains:FindFirstChild(clonedTrain.Name) do
task.wait(.1)
local randomNumber = math.random(1, 999)
clonedTrain.Name = "Train" .. math.random(1, 999)
end
end
clonedTrain.Parent = workspace.ActiveTrains
clonedTrain.Front.Ext.DestinationBoard.SurfaceGui.Destination.Text = clonedTrain.TrainInfo.Destination.Value
clonedTrain.Rear.Ext.DestinationBoard.SurfaceGui.Destination.Text = clonedTrain.TrainInfo.Destination.Value
clonedTrain:PivotTo(sidings[siding].SpawnBox.CFrame)
player:LoadCharacter()
local character = player.Character or player.CharacterAdded:Wait()
if character then
clonedTrain.Front.Drive:Sit(character:WaitForChild("Humanoid"))
character:WaitForChild("Humanoid").JumpPower = 0
spawnTrain:FireClient(player)
else
print("The player " .. player.Name .. ", has no character.")
clonedTrain:Destroy()
end
end
end
end
end)`
It is anchored but it is not collideable, is that a problem?
It has been set, because I can CFrame it only one time, but after that it gets destroyed
maybe you CFrame it out of the roblox limit part distance under the baseplate
What no? It CFrames perfectly fine, the problem is the primary part deletes
every part under -500 studs bellow 0 gets detroyed
maybe try CFraming the train like this ClonedTrain:SetPrimaryPartCFrame(CFrame.new())
try using model:MoveTo
instead of model:PivotTo
That literally won’t work because:
- I just told you the primary part gets destroyed
- SetPrimaryPartCFrame is deprecated anyway
I wish I could but I need CFrame because it’s the only way I can change orientation
but it still works so you should give it a try
??? Did you not read my reply? I literally said the PrimaryPart gets destroyed, so how do you expect me to use :SetPrimaryPartCFrame???
Then How Does The PrimaryPart magically disappear / gets destroyed
try replacing all the :Destroy()
statements with warn("Destroying!")
this should help log the error and see when it tries to destroy
Oh wow, that’s what I’m wondering at the moment!
I’ll try tomorrow, my computer is acting weird now.
do you have any client-side scripts? and I would like to know what player:LoadCharacter() do
I do have client scripts, it loads the character because CharacterAutoLoads is off