I want the part so spin once the part is touched and stops when the player moves away. What's the problem that causes the part to now stop. If the player touches the part the spinning will get faster.
Players = game:GetService("Players")
script.Parent.Touched:connect(function(hit)
local part = script.Parent
local moving = false
while wait() do
if hit.Parent:findFirstChild("Humanoid") and moving == false then
local player = Players:GetPlayerFromCharacter(hit.Parent)
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0.2,0)
moving = true
wait(.1)
elseif hit.Parent:findFirstChild("Humanoid") and moving == true then
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0,0)
moving = false
wait(.1)
end
end
end)

3 comments
Is it possible to move the part back to where it was before it started spinning without it being glitchy?
Create a new variable that saves the original CFrame, then use that variable to set it back whenever you wish.
k