I'm trying to create a vehicle, like a train or a tram system, one that can move relatively freely, take turns going up and down hills, etc. And seeing as though I'm new to scripting the only way I could really think to do this is to tween trams position, which I have done and the Tram moves pretty well in one direction. My initial idea was to have invisible non-colidable points in its way and when it hit those points it would tween its position again. However, upon thinking about it, im not sure how I would tween its rotation using C-frame whist simultaneously keeping it moving. And on top of this I can't tell if the player can still move the tram even while it's being tweened (this would be a problem for obvious reasons) (here is the current code if your wondering)
local Tram = script.Parent
local TweenService = game:GetService("TweenService")
local TramPos = Tram.Position
local DetectionPart = script.Parent
DetectionPart.Touched:Connect(function()
--print("Tram Detection Part Detected somthing")
end)
Instance.new("BodyVelocity", Tram)
local TwenInfo = TweenInfo.new(
50,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
2
)
local positionProperties = {
Position = Vector3.new(TramPos.X + 200, TramPos.Y, TramPos.Z)
}
local Tween = TweenService:Create(Tram,TwenInfo,positionProperties)
wait(5)
Tween:Play()
So my question is, is any other way I should be creating a vehicle like this? Is there any better alternative to what code I'm using right now?
