[SOLVED BY ME] Position-tweening boat model keeps going below the skybox. How can i fix this?
Asked by
5 years ago Edited 5 years ago
02 | local ts = game:GetService( "TweenService" ) |
04 | local boat = script.Parent.Parent |
06 | local placestogo = { Vector 3. new( 0.782 , - 7.5 , - 116.367 ), Vector 3. new( 35.282 , - 7.5 , - 82.117 ), Vector 3. new( 120.5 , - 7.5 , - 53.25 ) } |
08 | function tweenBoat(goal,thingToDo) |
09 | if thingToDo = = "turn" then |
10 | local tweeninfo = TweenInfo.new( 8 ,Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0 , false , 0 ) |
11 | local cframeValue = Instance.new( "CFrameValue" , script.Parent) |
12 | cframeValue.Value = script.Parent.CFrame |
13 | local tween = ts:Create(cframeValue, tweeninfo, { Value = goal } ) |
15 | cframeValue.Changed:Connect( function () |
16 | script.Parent.Parent:SetPrimaryPartCFrame(cframeValue.Value) |
18 | tween.Completed:Wait() |
21 | elseif thingToDo = = "move" then |
22 | local tweeninfo = TweenInfo.new( 8 ,Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0 , false , 0 ) |
23 | local vectorlookat = Instance.new( "Vector3Value" , script.Parent) |
24 | vectorlookat.Value = goal |
25 | local vectorvalue = Instance.new( "Vector3Value" , script.Parent) |
26 | vectorvalue.Value = script.Parent.Position |
27 | local tween = ts:Create(vectorvalue, tweeninfo, { Value = goal } ) |
29 | vectorvalue.Changed:Connect( function () |
30 | local positionWithYLeveled = Vector 3. new(vectorvalue.Value.X, vectorvalue.Value.Y, vectorvalue.Value.Z) |
31 | script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(positionWithYLeveled, vectorlookat.Value)) |
33 | tween.Completed:Wait() |
34 | vectorlookat:Destroy() |
36 | if script.Parent.Position.Y ~ = - 7.5 then |
37 | script.Parent.CFrame = CFrame.new(Vector 3. new(script.Parent.Position.X, - 7.5 , script.Parent.Position.Z), script.Parent.CFrame.LookVector) |
48 | tweenBoat(CFrame.new(script.Parent.Position, placestogo [ Destination ] ), "turn" ) |
50 | tweenBoat(placestogo [ Destination ] , "move" ) |
53 | Destination = Destination + 1 |
54 | if Destination = = 4 then |
So, the boat keeps going under and then returns without its other parts to destination 1 once it reaches destination 3. How can i fix this? I am not sure what is going wrong.