Issues with moving a player using CFrame

Alright so beforehand, yes everything is defined correctly, PlayerCharacter links to the corressponding player’s character and Spawn is linked to a brick.

So, I’m trying to move the player using this code and it’s made so it randomizes the position a bit so people don’t get stuck. However, they will not move. I’ve tried using all kinds of diffrent methods but none of them seem to work.

local SpawnPosition = Spawn.Position
	


local x = SpawnPosition.x
local y = SpawnPosition.y
local z = SpawnPosition.z
				
x = x + math.random(-1, 1)
z = z + math.random(-1, 1)
y = y + math.random(2, 3)


local lx = 0
local ly = y
local lz = 0
PlayerCharacter.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(x,y,z), Vector3.new(lx,ly,lz))

why use torso and not humanoidrootpart?

I’ve been used to using Torso for a long time now, I’ll see if switching it does anything.

and

Thanks, I never saw the SetPrimaryPartCFrame function. Definitely going to use this in some other scripts!