Examples
Definitions
RidePlayer_Server
Server script (Script) for the ride.
RidePlayer_Client
Client script (LocalScript) for the ride.
Simple Train Dispatcher
-- Dispatch button
local ServerStorage = game:GetService("ServerStorage")
local dispatchRideEvent = ServerStorage:WaitForChild("DispatchRideEvent")
local clickDetector = script.Parent.ClickDetector
local debounce = false
clickDetector.MouseClick:Connect(function()
if debounce == true then
return
end
debounce = true
dispatchRideEvent:Fire()
wait(1)
debounce = false
end)
-- RidePlayer_Server
local ServerStorage = game:GetService("ServerStorage")
-- continued...
local trainAnimPlayer = rideManager:GetTrainAnimationPlayer("TRAIN_NAME_HERE")
trainAnimPlayer:SetCurrentAnimation("ANIMATION_NAME")
local dispatchRideEvent = Instance.new("BindableEvent")
dispatchRideEvent.Name = "DispatchRideEvent"
dispatchRideEvent.Parent = ServerStorage
local function DispatchTrain()
if trainAnimPlayer:IsPlaying() then
return
end
trainAnimPlayer:Play()
end
dispatchRideEvent.Event:Connect(DispatchTrain)