NPC sliding away from spawn

I’ve wrote a script which is meant to have an npc walk around a sphere, kind of like this:
image

The NPC is sliding around on its own whenever I playtest the game. This doesn’t happen when I turn the script off. Here is the script:

local Player = workspace:WaitForChild("Player") -- player model
local Ground = workspace:WaitForChild("Ground") -- ground that the player is walking on

local run = game:GetService("RunService")
local Base = CFrame.new() -- empty CFrame, this will be updated later

run.Heartbeat:Connect(function()
	local PlayerPosition = Player:GetPivot().Position -- player model's position
	
	Base = CFrame.lookAt(PlayerPosition, Ground.Position) -- makes our blank cframe look at the ground. I use this to orientate the player model
	local X, Y, Z = Base:ToOrientation()
	
	local NewCFrame = CFrame.new(PlayerPosition) * CFrame.Angles(X + math.rad(90), 0, 0) -- The new cframe keeps the same position but updates the rotation
	Player:PivotTo(NewCFrame)
end)

A video of what’s happening can be seen here:

The rotation works just fine, it’s the sliding that’s causing issues

2 Likes