Rotating a Ball Opposite where the Character Walks

I’m trying to have a ball rotate underneath the character opposite the direction they walk, sort of like a hamster wheel or a treadmill. I’m having problems with the rotation though, because the ball rotates relative to its own axes rather than an axis perpendicular to where the character is moving.

As long as the ball is oriented close to (0,0,0) it works:


However when the ball is rotated off center weird stuff starts happening like:


I have a limited understanding of CFraming but I’ve spent the last couple days playing around and trying to come up with different ways of calculating the rotation, but none of them have worked.

Here is the present script (a local script in starterplayerscripts)

local plr = game.Players.LocalPlayer
local moon = workspace.moon
local c = moon.Size.X*math.pi
repeat wait() until plr.Character
local char = plr.Character

local function loop(dtime)
	moon.CFrame =,0,char.Torso.Position.Z) * CFrame.Angles(-math.rad(char.Torso.Position.Z),0,math.rad(char.Torso.Position.X))


Any help would be appreciated.