Hello everyone.
I have a problem with using tween service to move other parts physically.
I used Tween Service to move a train model so it can move players from a station to another (look in “Example 1”), but I realize that once a player jumps off of the seat or just don’t use the seat at all, the tween will ignore the fraction between the player and the floor (look in “Example 2”)
I’m trying to make the player move with the train, as 1 part, (look in “Example 3”)
Example 2
1 solution I thought of doing, is to weld the player to the floor, so the player doesn’t fly off of the train, however, it takes time to set up, and it doesn’t allow the player to move freely inside the train.
This is the script that I’m using, not sure how its gonna help but it’s here just in case:
tweenService = game:GetService("TweenService")
---------------------------------------------------------- START
Model = script.Parent
goal1 = script.Parent.Parent.Station1
origCFrame1 = Model.PrimaryPart.CFrame
tweenTime = 5
closeWaitTime = 0
easingStyle = Enum.EasingStyle.Sine
easingDirection = Enum.EasingDirection.InOut
repeats = 0
reverse = false
delayTime = 0
deb = false
info = TweenInfo.new(tweenTime, easingStyle, easingDirection, repeats, reverse, delayTime)
function tweenModel(model, CF)
CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
tween = tweenService:Create(CFrameValue, info, {Value = CF})
tween:Play()
tween.Completed:Connect(function()
CFrameValue:Destroy()
end)
end
wait(0)
tweenModel(Model, goal1.CFrame)
wait(5)
--------------------------SETP1
script.Parent.Elevator.Sound.PLAY.Disabled = false
Model = script.Parent
goal1 = script.Parent.Parent.TScanner2
origCFrame1 = Model.PrimaryPart.CFrame
tweenTime = 5
closeWaitTime = 0
easingStyle = Enum.EasingStyle.Sine
easingDirection = Enum.EasingDirection.InOut
repeats = 0
reverse = false
delayTime = 0
deb = false
info = TweenInfo.new(tweenTime, easingStyle, easingDirection, repeats, reverse, delayTime)
function tweenModel(model, CF)
CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
tween = tweenService:Create(CFrameValue, info, {Value = CF})
tween:Play()
tween.Completed:Connect(function()
CFrameValue:Destroy()
end)
end
wait(0)
tweenModel(Model, goal1.CFrame)
wait(5)
script.Parent.Elevator.Sound.STOP.Disabled = false
--------------------------SETP2
wait(1)
game.Workspace.Scanner2.Door.ScannerTween.Disabled = false
wait(6)
----------------------------------------------------------
script.Parent.Elevator.Sound.PLAY.Disabled = false
Model = script.Parent
goal1 = script.Parent.Parent.Station1
origCFrame1 = Model.PrimaryPart.CFrame
tweenTime = 5
closeWaitTime = 0
easingStyle = Enum.EasingStyle.Sine
easingDirection = Enum.EasingDirection.InOut
repeats = 0
reverse = false
delayTime = 0
deb = false
info = TweenInfo.new(tweenTime, easingStyle, easingDirection, repeats, reverse, delayTime)
function tweenModel(model, CF)
CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
tween = tweenService:Create(CFrameValue, info, {Value = CF})
tween:Play()
tween.Completed:Connect(function()
CFrameValue:Destroy()
end)
end
wait(0)
tweenModel(Model, goal1.CFrame)
wait(5)
script.Parent.Elevator.Sound.STOP.Disabled = false
wait(1)
script.Parent.MoonTrain.TrainDoors.ActiveDoorsR.Disabled = false
wait(20)
--------------------------SETP3
script.Parent.Elevator.Sound.PLAY.Disabled = false
Model = script.Parent
goal1 = script.Parent.Parent.TScanner1
origCFrame1 = Model.PrimaryPart.CFrame
tweenTime = 5
closeWaitTime = 0
easingStyle = Enum.EasingStyle.Sine
easingDirection = Enum.EasingDirection.InOut
repeats = 0
reverse = false
delayTime = 0
deb = false
info = TweenInfo.new(tweenTime, easingStyle, easingDirection, repeats, reverse, delayTime)
function tweenModel(model, CF)
CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
tween = tweenService:Create(CFrameValue, info, {Value = CF})
tween:Play()
tween.Completed:Connect(function()
CFrameValue:Destroy()
end)
end
wait(0)
tweenModel(Model, goal1.CFrame)
wait(5)
script.Parent.Elevator.Sound.STOP.Disabled = false
--------------------------SETP3.5
wait(1)
game.Workspace.Scanner1.Door.ScannerTween.Disabled = false
wait(6)
script.Disabled = true
script.Disabled = false
Please, if you have any idea about a solution, then please don’t hesitate to tell me about it.
Thank You.