I have a little train thingy here and it moves on really strange tracks for testing purposes.
Here is the code that moves the train:
for i = 1, #tracks:GetChildren(), 1 do
local nextTrack
if i == #tracks:GetChildren() then
nextTrack = tracks["Track"..1]
currentTrack = 1
else
nextTrack = tracks["Track"..i]
currentTrack = i
end
if nextTrack then
local attachment = nextTrack.TrackAttachment
repeat
task.wait()
local formula = math.round((engine.Position-attachment.WorldPosition).Magnitude)
print(nextTrack, attachment.WorldPosition)
until formula <= 5
prismconst.Attachment0 = attachment --PrismaticConstraint
prismconst.UpperLimit = nextTrack.Size.Z
engine.CFrame = attachment.WorldCFrame
print("attachment position that should be", attachment.WorldPosition, "engine position", engine.Position)
platform.CFrame = engine.CFrame * CFrame.new(0,1.5,0)
platform.VehicleSeat.Position = engine.Position + Vector3.new(0,2,0)
end
end
In the testing track there is approximately 56 track parts, and on the 53-54 it breaks.
Here is what my script prints:
And here is what on the server side: (script is a localscript with server running context btw)
Does somebody know how to fix this???