Hi everyone, I’ve been trying to look into trains and it’s been interesting. I was directed to a post where my issue of tweening a train was part solved. Anyways, the main issue is it’s saying ‘Unable to cast to dictionary’ and I don’t know why.
local TweenService = game:GetService("TweenService")
local Nodes = game.Workspace.NodeParts
local Train = game.Workspace:FindFirstChild("Vendablebackup's Class318")
local Speed = 16
function GetTime(Distance, Speed)
-- Time = Distance / Speed
local Time = Distance / Speed
return Time
end
local NewPoint = Nodes:WaitForChild("NodePart") -- New selected point/node
local Distance = (Train.PrimaryPart.Position - NewPoint.Position).magnitude -- Get the distance between the current position and the next node
local Time = GetTime(Distance, Speed) -- Calculate the time
print(Time)
local NewTweenInfoTable = TweenInfo.new(
Time,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local TrainTween = TweenService:Create(Train.PrimaryPart.CFrame, NewTweenInfoTable, NewPoint)
wait(1)
TrainTween:Play()
Here’s a script