im following gnome code's tutorial on a dead rails game, in the second episode I started having this problem, this is my second time using lua
local Players = game:GetService("Players")
local RunService =game:GetService("RunService")
local train = workspace.train
local seat = train.vehicleseat
local engine = train.engine
local prismaticConstraint = engine.PrismaticConstraint
local MAX_SPEED = 64
local currentTrackNumber = 1
local driver = nil
engine:SetNetworkOwner(nil)
RunService.Heartbeat:Connect(function(deltaTime)
local track = tracks:FindFirstChild("trackM" .. currentTrackNumber)
local nextTrack = tracks:FindFirstChild("trackM" .. currentTrackNumber + 1)
local progress = prismaticConstraint.CurrentPosition / track.PrimaryPart.Size.Z
print(progress)
end)
seat:GetPropertyChangedSignal("Occupant"):Connect(function(deltaTime)
local player = Players:GetPlayerFromCharacter(seat.Occupant.Parent)
if not player then return end
driver = player
end)
train.Throttleremote.OnServerEvent:Connect(function(player, throttle)
if player ~= driver then return end
prismaticConstraint.Velocity = math.clamp(throttle, -1, 1) * MAX_SPEED
end)