Check my script | 'Unable to cast to dictionary'

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

1 Like

It’s moving the newpoint and not the Train? How do I switch it around?

Did you change both to a dictionary?

No, I only changed the one he said to.