Checkpoint script not working

This script is supposed to spawn a player at a checkpoint when they spawn or respawn but it is not working. Why is this?

1 Like
char.HumanoidRootPart:PivtoTo(worksapce.Checkpoints[plr.leaderstats.Checkpoint.Value])
2 Likes

It did not work also alot of things are misspelled.

1 Like

Its misspelled because I just typed it fast into the chat, its not from the actual studio or anyting with type correction.

Also… can you put some prints or breakpoints in that code to see if the execution is even reaching the inner areas?

2 Likes

im not a master coder but i think you could use a spawn point and adjust its properties

1 Like

Anything in output?

heresyour30

1 Like

No it’s clear.

“Insert characters”

Put an else and print after each of those FindFirstChilds to figure out which one is bullying you.

or just put a print at the beginning of all of them thats smarter

1 Like

You need to add a wait after the last if statement.
When I tested with your code it had the exact same problem not going to the Part.

1 Like

Once the Roblox character loads in-game, it is moved to 0, 0, 0 or to a spawn location. To override this, you can add a slight delay using RunService.Stepped

local Checkpoints = workspace:WaitForChild("Checkpoints")
local RunService = game:GetService("RunService")

game:GetService("Players").PlayerAdded:Connect(function(player: Player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local checkpoint = Instance.new("StringValue")
	checkpoint.Name = "Checkpoint"
	checkpoint.Value = "Start"
	checkpoint.Parent = leaderstats

	player.CharacterAdded:Connect(function(character)
		if checkpoint.Value ~= "" and Checkpoints:FindFirstChild(checkpoint.Value) then
			RunService.Stepped:Wait()
			character:WaitForChild("HumanoidRootPart").CFrame = Checkpoints:FindFirstChild(checkpoint.Value).CFrame + Vector3.new(0, 3, 0)
		end
	end)
end)
2 Likes

Found the solution. Thank you all for your help.