Help With Obby Spinning tween

Ok so First Things First I am trying to make an Obby checkpoint that spins fast and slows down gradually but I don’t know the best way of doing this I have tried doing multiple tweens but it results in a very un-smooth spin here is my script and video:

local player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")

local SpinInfo1 = TweenInfo.new(0.2,Enum.EasingStyle.Linear)
local SpinInfo2 = TweenInfo.new(0.25,Enum.EasingStyle.Linear)
local SpinInfo3 = TweenInfo.new(0.3,Enum.EasingStyle.Linear)
local SpinInfo4 = TweenInfo.new(0.35,Enum.EasingStyle.Linear)
local SpinInfo5 = TweenInfo.new(0.4,Enum.EasingStyle.Linear)
local SpinInfo6 = TweenInfo.new(0.45,Enum.EasingStyle.Linear)

game.ReplicatedStorage.RemoteEvents.CheckPointReached.OnClientEvent:Connect(function()
	if player.leaderstats.Stage.Value ~= 0 or player.leaderstats.Stage.Value ~= 1 then
		local CheckPointMarker = game.Workspace.CheckPointMarkers:FindFirstChild("CheckPointMarker"..player.leaderstats.Stage.Value)
	
		print(player.leaderstats.Stage.Value)
		


		local Spin1 = TweenService:Create(CheckPointMarker,SpinInfo1,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(120),0)})
		local Spin1 = TweenService:Create(CheckPointMarker,SpinInfo1,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(240),0)})
		local Spin2 = TweenService:Create(CheckPointMarker,SpinInfo2,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(360),0)})
		local Spin3 = TweenService:Create(CheckPointMarker,SpinInfo3,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(120),0)})
		local Spin4 = TweenService:Create(CheckPointMarker,SpinInfo4,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(220),0)})
		local Spin5 = TweenService:Create(CheckPointMarker,SpinInfo5,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(305),0)})
		local Spin6 = TweenService:Create(CheckPointMarker,SpinInfo6,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(355),0)})
		
		Spin1:Play()
		Spin1.Completed:Connect(function()Spin2:Play() end)
		Spin2.Completed:Connect(function()Spin3:Play() end)
		Spin3.Completed:Connect(function()Spin4:Play() end)
		Spin4.Completed:Connect(function()Spin5:Play() end)
		Spin5.Completed:Connect(function()Spin6:Play() end)
	end
end)

and here is the video of what it looks like:
robloxapp-20220721-1622192.wmv (614.7 KB)

as you may notice the animation/tween is very much not smooth any help is much appreciated!

Hello!

The following script should work perfectly!

TweenService = game:GetService("TweenService")
spininfo = TweenInfo.new(0.3,Enum.EasingStyle.Linear)
spininfo2 = TweenInfo.new(1,Enum.EasingStyle.Sine)

Spin1 = TweenService:Create(script.Parent,spininfo,{CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(120),0)}) 
Spin2 = TweenService:Create(script.Parent,spininfo,{CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(240),0)})
Spin3 = TweenService:Create(script.Parent,spininfo2,{CFrame = script.Parent.CFrame * CFrame.Angles(0,math.rad(360),0)})

local HasTouched = false --variable so that only when the player touches the part for the first time it will play the animation.

script.Parent.Touched:Connect(function(hit)
	local h = hit.Parent:FindFirstChild("Humanoid")
	if h then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)	
		if player then
			if HasTouched == false then
				HasTouched = true
				Spin1:Play()
				Spin1.Completed:Connect(function()Spin2:Play() end)
				Spin2.Completed:Connect(function()Spin3:Play() end)
			end
		end
	end
end)

You said it was an obby, so obviously, you could only claim the checkpoint once. That’s why I added a variable for that. so that the animation doesn’t play every time the player touches the checkpoint, but only the first time.

Btw, this is a ServerScript parented to a part (the checkpoint).

1 Like

Thank you for the help I will try it out once I get a chance, Btw yes your right about the only touched once thing, however for my game I use a local script for the tween because it’s less laggy so I have another script from the server that detects when a part is touched, if the part is a ch checkpoint and the checkpoint is + 1 of the stages value then it fires the client side

1 Like

You’re welcome.
And yes, this should still work if you use a localscript!

Yeah it should another reason that’s it’s local is because I don’t want every player in the game to see the animation

1 Like

ok now that I’ve finally tested it it still has the same issue because the tween isn’t smooth it goes fast at the beginning and slows down really fast at the start of the third tween

robloxapp-20220724-2153297.wmv (458.5 KB)

This is weird because when I tested it, it worked perfectly. For some reason, I can’t open your file.

But it should look like this:

Tips:

I also got a question; did you use the exact same script as me, or did you edit it a bit? if you did could you please show it to me.

Thanks in advance.

Edit: Also check if you used the correct time in the tweeninfo’s :wink:

As you can see yes I did do all of your requests I did edit the script a bit but it shouldn’t matter you can check it yourself, even on your checkpoint I can see it slows down really fast at one point I want it to slow down slower, here is my script:

local player = game.Players.LocalPlayer
local TweenService = game:GetService("TweenService")

local SpinInfo = TweenInfo.new(0.3,Enum.EasingStyle.Linear)
local SpinInfo2 = TweenInfo.new(1,Enum.EasingStyle.Sine)

game.ReplicatedStorage.RemoteEvents.CheckPointReached.OnClientEvent:Connect(function()
	if player.leaderstats.Stage.Value ~= 0 or player.leaderstats.Stage.Value ~= 1 then
		local CheckPointMarker = game.Workspace.CheckPointMarkers:FindFirstChild("CheckPointMarker"..player.leaderstats.Stage.Value)
	
		print(player.leaderstats.Stage.Value)
		local Spin1 = TweenService:Create(CheckPointMarker,SpinInfo,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(120),0)})
		local Spin2 = TweenService:Create(CheckPointMarker,SpinInfo,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(240),0)})
		local Spin3 = TweenService:Create(CheckPointMarker,SpinInfo2,{CFrame = CheckPointMarker.CFrame * CFrame.Angles(0,math.rad(360),0)})
		
		
		Spin1:Play()
		Spin1.Completed:Connect(function()Spin2:Play() end)
		Spin2.Completed:Connect(function()Spin3:Play() end)
	end
end)

ok so literally a minute after I played with the tween info and changed the time to match up so it was really smooth. Thanks so much I couldn’t have done this without you!

1 Like

Congrats, you did it on your own! I hope this helped you understand a bit about all those spin animation. You’re welcome

1 Like