Skip to content

Roblox Track Ride Framework API Reference

This is the API for RobloxTrackRideFramework.

If a class is not explained or defined, it is because it is not meant to be accessed.


Signal

Lua-side duplication of the API of events on Roblox objects. Signals are needed for to ensure that for local events objects are passed by reference rather than by value where possible, as the BindableEvent objects always pass signal arguments by value, meaning tables will be deep copied. Roblox's deep copy method parses to a non-lua table compatable format.

Similar to RBXScriptSignal

Connect

Signal:Connect(func: function) -> RBXScriptConnection

Connect a new handler to the event. RBXScriptConnection that can be disconnected.

Wait

Signal:Wait() -> Variant

Yields the current thread until this signal is fired. Returns what was fired to the signal.


RideManager

RideManager {
    Name: string,

    TrackManager: TrackManager,
    AnimationManager: AnimationManager,

    TrainAnimationPlayers: TrainAnimationPlayer[]
}

Keeps track of all of the Tracks, TrainAnimations, and TrainAnimationPlayers for a given ride.

Update

RideManager:Update(stepped: number) -> nil

Updates all TrainAnimationPlayers in this manager.

GetTrainAnimationPlayer

RideManager:GetTrainAnimationPlayer(name: string) -> TrainAnimationPlayer?

Returns the first TrainAnimationPlayer with the given name. Can return nil.

GetTrainAnimationPlayersWithTag

RideManager:GetTrainAnimationPlayersWithTag(tagName: string) -> TrainAnimationPlayer[]

Returns an array of TrainAnimationPlayers with the given tag.

RideManager_Server

Extends RideManager

RideManager_Server {
    ServerData: Folder
}

RideManager for Server. Syncs TrainAnimationPlayers, TrainAnimations, and Tracks to Clients.

ServerData should be parented to a Client visible Service (like ReplicatedStorage) before Ready() is called.

FromInstance

RideManager_Server.FromInstance(instance: Instance) -> RideManager_Server, Folder

Along with the object, returns a Folder, the ServerData. This should be parented to a Client visible Service (like ReplicatedStorage) before Ready() is called.

Instance Data Tree:

instanceData: Instance
    +--> Name: StringValue?
    +--> TrainAnimationPlayers: Instance
    |       +--> [ANY_NAME]: Instance
    |       |       +--> IsPlaying: BoolValue
    |       |       +--> IsLooped: BoolValue
    |       |       +--> StartAnimation: StringValue
    |       |       |       // if nil, IsPlaying, StartDelay, and StartTime are not used
    |       |       +--> StartDelay: NumberValue
    |       |       +--> StartTime: NumberValue
    |       |       +--> TrainModel: Model
    |       |               // See CFrameTrain for Instance data setup
    |       ...
    |       +--> [ANY_NAME_B]: Instance
    |               + ...
    +--> TrainAnimations: Instance
    |       +--> [ANY_NAME]: ModuleScript
    |       ...
    |       +--> [ANY_NAME_B]: ModuleScript
    +--> Tracks: Instance
            +--> [ANY_NAME]: Instance/ObjectValue
            |       +--> TrackClass: StringValue
            |       // See CFrameTrack for Instance data setup
            +--> [ANY_NAME_B]: Instance/ObjectValue

Ready

RideManager_Server:Ready() -> nil

Readies this RideManager. Signals to all clients they can load the ServerData.

Unready

RideManager_Server:Unready() -> nil

Unreadies this RideManager.

RideManager_Client

Extends RideManager

RideManager_Client {
    ServerData: Folder
}

Client-side version of RideManager. Updates the CFrame positions of all the train models.

new

RideManager_Client.new(serverData: Folder) -> RideManager_Client

Constructor.

serverData is the Folder created by RideManager_Server. It contains all of the Instances and data used to sync between Server and Client. Make sure this is visible to the Client.


TrainAnimationPlayer

TrainAnimationPlayer {
    Name: string,

    AnimationPlayer: AnimationPlayer,
    CFrameTrainModel: CFrameTrainModel,

    CurrentTime: number,
    CurrentTrackSpeed: number,
    CurrentPosition: number,

    Tags: string[]
}

Plays an Animation and updates it's Train Model.

ANIMATION_STATE

Enum

TrainAnimationPlayer.ANIMATION_STATE {
    PLAYING: 0,
    PAUSED: 1,
    STOPPED: 2,
}

Signals

OnPlaying

TrainAnimationPlayer.OnPlaying()

Fired when the AnimationPlayer's CurrentState changes to PLAYING.

OnPaused

TrainAnimationPlayer.OnPaused()

Fired when the AnimationPlayer's CurrentState changes to Paused.

OnStopped

TrainAnimationPlayer.OnStopped()

Fired when the AnimationPlayer's CurrentState changes to Stopped.

OnStateChanged

TrainAnimationPlayer.OnStateChanged(newState: ANIMATION_STATE)

Fired when the AnimationPlayer's CurrentState changes.

OnLooped

TrainAnimationPlayer.OnLooped()

Fired when the AnimationPlayer loops it's animation.

OnUpdated

TrainAnimationPlayer.OnUpdated()

Fired after the TrainAnimationPlayer updates the position of it's CFrameTrainModel.

IsPlaying

TrainAnimationPlayer:IsPlaying() -> boolean

Returns true if the AnimationPlayer's CurrentState is PLAYING.

IsPaused

TrainAnimationPlayer:IsPaused() -> boolean

Returns true if the AnimationPlayer's CurrentState is PAUSED.

IsStopped

TrainAnimationPlayer:IsStopped(tagName: string) -> boolean

Returns true if the AnimationPlayer's CurrentState is STOPPED.

IsLooping

TrainAnimationPlayer:HasTag(tagName: string) -> boolean

Returns true if the AnimationPlayer's IsLooped value is true.

GetTrigger

TrainAnimationPlayer:GetTrigger(triggerName: string) -> Signal

Returns a Signal that will be fired if the currently playing Animation passes it.

GetCurrentTrainModel

TrainAnimationPlayer:GetCurrentTrainModel() -> Model?

Returns CFrameTrainModel's CurrentModel. Can be nil.

GetCurrentState

TrainAnimationPlayer:GetCurrentState() -> ANIMATION_STATE

Returns the current state of the animation player.

HasTag

TrainAnimationPlayer:HasTag(tagName: string) -> boolean

Returns true if it has the given tag.

AddTag

TrainAnimationPlayer:AddTag(tagName: string) -> nil

Adds the given tag to itself.

SetIsLooped

TrainAnimationPlayer:SetIsLooped(value: boolean) -> nil

Set's whether the AnimationPlayer will automatically Restart when the Animation's length is reached.

SetCurrentAnimation

TrainAnimationPlayer:SetCurrentAnimation(newAnimationName: string, keepCurrentTime: boolean) -> nil

Set's the AnimationPlayer's current animation to newAnimationName. If keepCurrentTime is not true, will reset the current time to 0.

SetCurrentTime

TrainAnimationPlayer:SetCurrentTime(newCurrentTime: number) -> nil

Set's the AnimationPlayer's current time to newCurrentTime

SetTrainModel

TrainAnimationPlayer:SetTrainModel(model: Model?) -> nil

Set's CFrameTrainModel model to model. Can be nil.

Restart

TrainAnimationPlayer:Restart() -> nil

Sets the CurrentTime to 0 and the current state to PLAYING

Play

TrainAnimationPlayer:Play() -> nil

Sets the current state of the AnimationPlayer to PLAYING. If the previous state was STOPPED, resets the CurrentTime to 0.

Pause

TrainAnimationPlayer:Pause() -> nil

Sets the current state of the AnimationPlayer to PAUSED.

Stop

TrainAnimationPlayer:Stop() -> nil

Sets the current state of the AnimationPlayer to STOPPED.

BindUpdate

TrainAnimationPlayer:BindUpdate(trainAnimationPlayer: TrainAnimationPlayer, offset: number? = 0) -> nil

Binds this TrainAnimationPlayer to the given TrainAnimationPlayer so that it can use it's CurrentTime. Offset will be added to current time to get a new result.

UnbindUpdate

TrainAnimationPlayer:UnbindUpdate() -> nil

Unbinds this TrainAnimationPlayer from the currently bound animation player so that it can utilize it's own TimeUpdater.

TrainAnimationPlayer_Server

Extends TrainAnimationPlayer

TrainAnimationPlayer_Server {
    ServerData: Folder,
}

Server-side version of TrainAnimationPlayer.

TrainAnimationPlayer_Client

Extends TrainAnimationPlayer

TrainAnimationPlayer_Client {
    ServerData: Folder,
}

Client-side version of TrainAnimationPlayer.


CFrameTrainModel

CFrameTrainModel {
    CurrentModel: Model,

    CFrameTrain: CFrameTrain,
    DefaultCFrame: CFrame,
}

Rigs a train Model and provides methods to move and position it. Also keeps track of seats.

Signals

OnPlayerSeated

CFrameTrainModel.OnPlayerSeated(player: Player, seat: Seat)

Fired when a Player's Character sits in a seat in the train.

OnPlayerUnseated

CFrameTrainModel.OnPlayerUnseated(player: Player, seat: Seat)

Fired when a Player's Character jumps out of or exits in a seat in the train.

OnModelChanged

CFrameTrainModel.OnModelChanged(currentModel: Model)

Fired when the CurrentModel changes, even to nil.

OnModelRemoving

CFrameTrainModel.OnModelRemoving(currentModel: Model)

Fired before the CurrentModel is removed.

OnUpdated

CFrameTrainModel.OnUpdated(currentModel: Model)

Fired when the workspace position of the CurrentModel is set using SetWheelSetPositions()

GetSeat

CFrameTrainModel:GetSeat(carIndex: number, rowIndex: number, seatIndex: number) -> Seat?

Returns the seat with the given indexes.

SetModel

CFrameTrainModel:SetModel(newModel: Model?) -> nil

Sets the current model for this CFrameTrainModel. Resets the CFrameTrain and refreshes the seats.

If nil, sets current model to nil

SetInDefaultPosition

CFrameTrainModel:SetInDefaultPosition() -> nil

Sets the train in a default position given by CFrameTrainModel.DefaultCFrame, usually below the map. Useful if you want to hide the train model.

CFrameTrainModel_Server

Extends CFrameTrainModel

CFrameTrainModel_Server {
    SeatsDisabled: boolean,
    SeatedPlayersCanJump: boolean,
    OpenSeatsDisabled: boolean,

    ServerData: Folder,
}

Server-side version of CFrameTrainModel. Syncs the CurrentModel to Clients and provides methods to edit seats and seated players.

SetSeatedPlayersCanJump

CFrameTrainModel_Server:SetSeatedPlayersCanJump(newValue: boolean) -> nil

If true, prevents seated Players and future Players who sit down in the train from jumping out of their seat.

If false, allows seated Players to jump again.

SetSeatsDisabled

CFrameTrainModel_Server:SetSeatsDisabled(newValue: boolean) -> nil

If true, disables all seats in the train. If there are any Players seated in the train, they will jump out. Make sure you enable their Jump before you disable their seat!

If false, enables all seats in the train allowing players to sit in them again.

DisableOpenSeats

CFrameTrainModel_Server:DisableOpenSeats() -> nil

Disables any open seats in the train. Player's already seated will NOT be ejected.Useful before dispatching the train.

SetCanUpdatePosition

CFrameTrainModel_Server:SetCanUpdatePosition(newValue: boolean) -> nil

Disables/enables Client updating for this TrainModel. Useful for client-side optimization.

CFrameTrainModel_Client

Extends CFrameTrainModel

CFrameTrainModel_Client {
    SeatedPlayersCanJump: boolean,
    PlayerIsSeatedInTrain: boolean,

    OverrideServerCanUpdatePosition: boolean,
    CanUpdatePosition: boolean,
}

Client-side version of CFrameTrainModel. Provides optimizations for updating the train model in the workspace.

Depending on the amount of parts and subchildren in the train model, updating the position of a model can add extra strain to your Player's device.

You can use SetCanUpdatePosition to turn off updating. This is useful if the train is not visible to player. It does not affect the animation updating and trigger firing.

Signals

OnLocalPlayerSeated

CFrameTrainModel_Client.OnLocalPlayerSeated(player: Player, seat: Seat)

Fired when the client's Character sits in a seat in the train.

OnLocalPlayerUnseated

CFrameTrainModel_Client.OnLocalPlayerUnseated(player: Player, seat: Seat)

Fired when the client's Character jumps out of or exits in a seat in the train.

SetOverrideServerCanUpdatePosition

CFrameTrainModel_Client:SetOverrideServerCanUpdatePosition(newValue: boolean) -> nil

Overrides the Server's CanUpdatePosition value. Use if you would like a train to be visible and vice versa even if the server says it shouldn't.

SetCanUpdatePosition

CFrameTrainModel_Client:SetCanUpdatePosition(newValue: boolean) -> nil

Sets whether the train model's position should be updated. Useful for optimization.