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)
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)
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?
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
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
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
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).
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.)
Still isnât working, no errors so Iâm assuming it isnât finding checkpoint.