So I have this script that moves a model that contains a train model and a sea when W is pressed.Everything works fine except for the fact that the player is left behind when the train is moving.
seat = script.Parent tram = script.Parent.Parent plr = seat.Occupant while true do if seat.Occupant ~= nil then print("sitting") seat.Occupant.Parent.isDriving.Value = true print (tram.forward.Value) while tram.forward.Value == true do --print(tram.tram.Position) --seat.Position = seat.Position + Vector3.new(0, 0, -1) --tram.Position = tram.Position + Vector3.new(0, 0, -1) tram:SetPrimaryPartCFrame(tram:GetPrimaryPartCFrame() * CFrame.new(0,0,-1)) --seat.Occupant.Parent.HumanoidRootPart.Position = seat.Position wait() end while tram.backward.Value == true do wait() end end wait() end
What am I doing wrong?
As far as I am aware, CFrames 'set' a part's location, whilst Vector3s 'move' its location. Try attaching the player to the seat, or using Vector3s and .position instead of CFrames.