I’m making a turn-back system for my train, and for my method, I need to change its CFrame. For that, I need to change the primary part’s CFrame, but for some reason, whenever the train is cloned to Workspace (to spawn), I discovered that it gets destroyed and the script errors.
I have no idea why this is and the only script in the game that actually references the train this early is this one:
local clonedTrain = trains[trainName]:Clone()
clonedTrain.Parent = workspace.ActiveTrains
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
Can someone please shed some light on this, because I have seen no one talk about it.
Edit: It’s almost midnight where I live, so please drop replies so I can read them in the morning.
But nothing would error, because all it’s doing is looping. And plus that code never actually runs, the only thing that is there for is if a player leaves or respawns while the train is spawning
I’ve never actually seen it delete the train no, because usually that specific scenario never occurs and I would also know because there is a print statement