Setting the Player's position

Did you put it in ServerScriptService?

First issue is your using Position with CFrame, so what we need to do is:
Player.Character:SetPrimaryPartCFrame(CFrame.new(workspace.Checkpoints:FindFirstChild(ServerData[Player].leaderstats.Level).CFrame))

(also removed un-needed things)

image

Can you send your entire script, as I have something setup like what your trying to do and its working fine. (or at least part of your script)

I have found the issue of that error:
You were using CFrame.new()
So try this instead Player.Character:SetPrimaryPartCFrame(workspace.Checkpoints:FindFirstChild(ServerData[Player].leaderstats.Level).CFrame)

1 Like

I think the problem is the .CFrame at the end, thats the part that isn’t working. It should be getting a Vector3 (Position).

Thats not the issue trust me, you were using CFrame.new() and you were giving CFrame.new a CFrame

Okay, with the updated one you sent, it’s still not working. Same error.

Can you send they chunk of current code as I dont have much info, make sure the player is getting added to the table also.

You’re indexing the “ServerData” table using the player instance, but how did you set the value in the first place? Are you sure you’re using the player instance there too or instead use the name/userID?

1 Like

Yes, it is. I’ve tried this in a separate script and just replaced ServerData[Player] with 1. Still have the same error.

You forgot a do on the end of that for i, v in pairs loop

1 Like

I’m using the Player’s UserId to save their data.

Then you have to retrieve it using the Player’s UserId, not instance. Table key and value types stay the same, and are type sensitive.

local HRP = Character:WaitForChild("HumanoidRootPart")
HRP.CFrame = game.Workspace.Checkpoints:WaitForChild(tostring(ServerData[Player.UserId].leaderstats.Level)).CFrame
1 Like

Then thats an issue if you using the player id to save it and then using the instance to get it it will cause a problem.

local function LoadData(Player)
	local Data
	local Success, Error = pcall(function() Data = PlayerData:GetAsync("Data:"..Player.UserId) end)
	if not Success then
		warn("Could not get data for: "..Player.Name)
	end
	if not Data then
		Data = NewData()
	end
	ServerData[Player] = Data
end

I’m setting ServerData[Player] to Data

1 Like
local checkpointName = tostring(ServerData[Player].leaderstats.Level)
local checkpoint = workspace.Checkpoints:FindFirstChild(checkpointName)

print(checkpointName, checkpoint, typeof(Player), (typeof(Player) == "Instance") and Player.ClassName or nil) -- Debugging to check the checkpoint

if checkpoint then
    Character:SetPrimaryPartCFrame(checkpoint.CFrame + Vector3.new(0, 5, 0))
end

Try this and give me the results from the print (should be in output).

image

Did the teleport work? Also are you sure checkpoint 0 is actually somewhere else and you’re not already on it? (I also edited the code a bit, try copying and trying it again.)

image

Still isn’t working, no errors so I’m assuming it isn’t finding checkpoint.