Trying to make random checkpoint system. Not working well

I am basically trying to make a system that randomly sets respawn points. (Like a random check point obby) I want to make it so that if you die, you respawn at your most recent random checkpoint.
Probably too much for 1 post, but I want to also have a system that lets you go back checkpoints if you have a problematic respawn spot that kills you.

I currently have this:

local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid

local VectorZero =, 0, 0)
local moving = false 

local function Moved()		
	if Humanoid.MoveDirection ~= VectorZero then
		Humanoid.WalkSpeed = 25
		 moving = true
		print("Stopped Moving")
		moving = false 


if moving == false  then
	if math = 10 then

(im aware that line 23 is incomplete)
Things im having issues with:

  • No idea how to get the player’s position
  • Getting a random error that I cant figure out at line 22
  • I really have no idea how to make them respawn at this random point.

Could someone please help? Thanks.

Sure, I’d be happy to help! To address your first issue, you can get a player’s position using the Character object’s Position property. For example, to get the LocalPlayer’s position, you would use local pos = Character.Position.

As for the second issue, the error you’re getting is likely because of the equality comparison on line 22. You should use the == operator to check for equality instead of =, which is an assignment operator. So your code should be:

if math.random(1, 25) == 10 then

Finally, to make the player respawn at the checkpoint, you can use the HumanoidRootPart property’s CFrame property to set the respawn location. For example, to set the player’s respawn location to a Vector3 position checkpointPos, you would use HumanoidRootPart.CFrame =

1 Like

Thank you so much! That is EXTREMELY helpful!!! :heart:

No problem. If you ever need me, just yell my name. Lol

1 Like

oh yeah, would I define pos at the start of the script, or only after they arent moving?
sorry very new to this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.