How to make object spin when touched?

I been looking though YouTube and can not find a tutorial on how to make a object like a checkpoint spin, or have a effect when touched like in (3) Dim’s Difficulty Chart Obby (DDCO) - Roblox, or (3) Tiny’s Difficulty Chart Obby Remastered - Roblox.

1 Like

You can use TweenService | Roblox Creator Documentation to tween the orientation. A slight catch is that using it on the part directly will only allow a limited range of rotation so to get around it you can tween an IntValue that has a Changed connection to update the rotation of the part.

Here’s the code for a quick proof of concept that you can extend off of:

local debounce = false

script.Parent.Touched:Connect(function(hit) -- script.Parent is the checkpoint part
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player and not debounce then
		debounce = true
		local rotation ="IntValue") -- create IntValue to hold rotation value
		rotation.Changed:Connect(function(value) -- create a connection to update rotation of part as it tweens
			script.Parent.Orientation =,value,0)
		local tween = game:GetService("TweenService"):Create(rotation,, {Value = 360*5}) -- tween the part 5 times in 3 seconds
		tween.Completed:Wait() -- wait for tween to end
		rotation:Destroy() -- delete IntValue (which also deletes connection) to prevent memory leaks
		debounce = false

Yo thanks so much I been looking every where and can’t find a thing!

This is very useful for people who are learning to include CFrames into their tweens. This actually helped me a lot to since im kinda new to scripting and I was wondering how to make my CFrame tween out smoothly.