Danster375
(danDeveloper)
March 29, 2023, 8:34pm
#1
Hello. I am using TweenService to create a swing theme park ride.

I am having an issue where I set a tween to tween the angle of the ride arm/swinging part to 110 degrees. Then it will go to -110 degrees/swing the other side at the same height. The ride goes over the top as that is the quickest path to the angle. Is they anyway I can stop this?

(I am not sure if you would need to code so please tell me if you do!)

You can subtract the degrees by -110 instead of setting it to -110.

Danster375
(danDeveloper)
March 29, 2023, 8:39pm
#3
Hey thanks for your reply
How would I do this?

I have never really tried anything this much with TweenService before I have only done a couple of things with it in the past so I am not to sure how to subtract degrees.

Can you show me the full script that you have?

You can do something like this:

```
local Swing = workspace.Swing
Swing.CFrame = CFrame.new(Swing.CFrame.Position) * CFrame.Angles(math.rad(Swing.Orientation.X - 110), 0, 0)
```

(this will probably not work for you im just showing you an example)

Danster375
(danDeveloper)
March 29, 2023, 8:47pm
#6
Here it is:

```
local button = script.Parent.Button.ClickDetector
local TweenService = game:GetService("TweenService")
local swingingPart = script.Parent.SwingingPart
local swing1TweenPoint = {CFrame = swingingPart.CFrame * CFrame.Angles(math.rad(15), 0, 0)}
local swing2TweenPoint = {CFrame = swingingPart.CFrame * CFrame.Angles(math.rad(-25), 0, 0)}
local swing3TweenPoint = {CFrame = swingingPart.CFrame * CFrame.Angles(math.rad(50), 0, 0)}
local swing4TweenPoint = {CFrame = swingingPart.CFrame * CFrame.Angles(math.rad(-70), 0, 0)}
local swing5TweenPoint = {CFrame = swingingPart.CFrame * CFrame.Angles(math.rad(110), 0, 0)}
local swing6TweenPoint = {CFrame = swingingPart.CFrame * CFrame.Angles(math.rad(-110), 0, 0)}
local swing1TweenInfo = TweenInfo.new(
3.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0
)
local swing1Tween = TweenService:Create(swingingPart, swing1TweenInfo, swing1TweenPoint)
local swing2TweenInfo = TweenInfo.new(
4,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0
)
local swing2Tween = TweenService:Create(swingingPart, swing2TweenInfo, swing2TweenPoint)
local swing3TweenInfo = TweenInfo.new(
4,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0
)
local swing3Tween = TweenService:Create(swingingPart, swing3TweenInfo, swing3TweenPoint)
local swing4TweenInfo = TweenInfo.new(
4.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0
)
local swing4Tween = TweenService:Create(swingingPart, swing4TweenInfo, swing4TweenPoint)
local swing5TweenInfo = TweenInfo.new(
4.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0,
false
)
local swing5Tween = TweenService:Create(swingingPart, swing5TweenInfo, swing5TweenPoint)
local swing6TweenInfo = TweenInfo.new(
4.5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0
)
local swing6Tween = TweenService:Create(swingingPart, swing6TweenInfo, swing6TweenPoint)
local function cycle()
print("Swinging ride system starting: Using Tween")
wait(1)
swing1Tween:Play()
swing1Tween.Completed:Connect(function()swing2Tween:Play() end)
swing2Tween.Completed:Connect(function()swing3Tween:Play() end)
swing3Tween.Completed:Connect(function()swing4Tween:Play() end)
swing4Tween.Completed:Connect(function()swing5Tween:Play() end)
swing5Tween.Completed:Connect(function()swing6Tween:Play() end)
end
button.MouseClick:Connect(function()
wait(1)
cycle()
end)
```

you could have another tween that makes it go back to the starting position and then tween it to your final point to make a â€śswingâ€ť motion

1 Like

Danster375
(danDeveloper)
March 29, 2023, 8:56pm
#8
I have tried to make that. It looks really janky as it stops at the bottom then goes back up.

If i make it a EasingStyle linear to make a smooth swing it is very janky and just stops at 110 degrees.

Danster375
(danDeveloper)
March 29, 2023, 9:09pm
#9
Sorted the problem!
Thank you everyone who helped me.

I added another Tween after one and changed the previous Tweenâ€™s EasingStyle to In and changed the new Tweenâ€™s EasingStyle to Out . I also divided the time by 2 so the correct speed could continue over the 2 tweens!

Thank you

system
(system)
Closed
April 12, 2023, 9:09pm
#10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.