Nothing happens when changing the HumanoidRootParts's CFrame

Hello people, I’m making a simple checkpoint system that teleports the player to the last checkpoint they were at. Everything is working fine, Until I actually try to teleport the character to the checkpoint. There are no errors in the console, and i’ve set up print statements to check if the code is failing somewhere. But it continues with the rest of the code as if it did teleport the player to the checkpoint.

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local checkpoints = game.Workspace.CheckPoints.Checkpoints:GetChildren()
local currentcheckpoint = nil



-- Getting the checkpoints and waiting for them to be touched (Player has not respawned yet) --
for i, v in pairs(checkpoints) do
	v.Touched:Connect(function()
		if currentcheckpoint ~= v then
			currentcheckpoint = v
			print(v)
		end
	end)
end


-- Player has respawned do exactly what i was doing before, Except set their spawn to the currentcheckpoint --
plr.CharacterAdded:Connect(function()
	if currentcheckpoint ~= nil then
		
		
		print("TELEPORTING NOW")
		char:WaitForChild("HumanoidRootPart").CFrame = currentcheckpoint.CFrame
		print("TELEPORTED PLAYER")
		
		
		
		for i, v in pairs(checkpoints) do
			v.Touched:Connect(function()
				if currentcheckpoint ~= v then
					currentcheckpoint = v
					print(v)
				end
			end)
		end
	end
end)

Here’s a video of the issue:

I’m just a bit confused, if anyone knows why or has any potential solutions please let me know, and thank you for your time.

1 Like

For change the player position, you will need a Script instead of a LocalScript.

Use this for the Local Script call a Script Service

task.wait()
	local plr = game.Players.LocalPlayer
	local char = plr.Character or plr.CharacterAdded:Wait()

	local checkpoints = game.Workspace.CheckPoints:GetChildren()
	local currentcheckpoint = nil



	-- Getting the checkpoints and waiting for them to be touched (Player has not respawned yet) --
	for i, v in pairs(checkpoints) do
		v.Touched:Connect(function()
			if currentcheckpoint ~= v then
				currentcheckpoint = v
				print(v)
			end
		end)
	end


	-- Player has respawned do exactly what i was doing before, Except set their spawn to the currentcheckpoint --
	plr.CharacterAdded:Connect(function(char)
		plr.CharacterAdded:Wait()
		if currentcheckpoint ~= nil then

		print("Teleporting "..plr.Name)
			game.ReplicatedStorage.RemoteEvent:FireServer(currentcheckpoint)
		print("Teleported "..plr.Name)

			for i, v in pairs(checkpoints) do
				v.Touched:Connect(function()
					if currentcheckpoint ~= v then
						currentcheckpoint = v
						print(v)
					end
				end)
			end
		end
	end)

And use this Script in the ScriptService


game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,checkpoint)
	
	local Char = plr.Character or plr.CharacterAdded:Wait()
	
	local HumanoidRootPart = Char:WaitForChild("HumanoidRootPart")
	
	HumanoidRootPart.CFrame = checkpoint.CFrame
	
end)

This doesn’t work, Changing the players CFrame doesn’t need to happen on the server, Since the game will be set to 1 max player per server, there will be no other players. So there is no need to change the CFrame for all the other players

The characters CFrame still isn’t being changed

Sorry! I added more information than I should have

plr.CharacterAdded:Connect(function(char)
		plr.CharacterAdded:Wait() -- <- Remove This
		if currentcheckpoint ~= nil then

Video of Script Working:

1 Like

Hmmm yeah this isn’t working, Seeing that it’s working for you means that its most likely another one of my scripts that is messing with it. Ill probably have to go through them and see what could be causing the issue. I appreciate the help

1 Like

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