I’m tweening 2 models, and I want them to move at the exact same speed but in a different and changing direction and distance. I have 2 “roads” of waypoints (parts) that represent where I want them to go, and I want them to move at the same time.
Waypoints1= --table of parts that make the path model1 follows
Waypoints2= --same thing, but for model2
local count1= 1
local count2 = 1
local function Move(model)
local nextplace
local currentplace = model.Position --simplified for clarity
local nextcframe
If model.Name == "Model1" then
nextplace = Waypoints1[count1].Position
nextcframe = Waypoints1[count1].CFrame
else
--same thing, but for model2, Waypoints2, and count2
end
local Speed = 5
local Distance = math.abs(currentplace.Magnitude - nextplace.Magnitude)
local time = Distance/Speed
local tween = TweenService:Create(model,TweenInfo.new(time),{CFrame = nextcframe})
tween:Play()
tween.Completed:Connect(function()
tween:Destroy()
count1 += 1
--if model2 then count2
Move(model)
end)
end
Move(Model1)
Move(Model2)
This is what I have so far. One of them is moving much faster than the other. What am I doing wrong?