Obby Stage System Optimization/Advice

So, recently, I’ve been developing an obstacle course, titled “datas ep1c 0bby of d00mz!”.

Rather than using an older team-style system to save progress, I’ve opted to use a leaderstats “Stage” IntValue.


	--Calculate new spawn
	local playerStage = player.leaderstats.Stage.Value
	local stageName = "Spawn" .. playerStage
	character:WaitForChild("HumanoidRootPart").CFrame = workspace.Spawns[stageName].CFrame + Vector3.new(0,1,0)

Would it be more optimal to instead save the CFrame of each spawn block in a table when the game is first launched, then access that table with the Stage value as the key, or is this method probably fine? I guess a little nit-picky, but I want the game to feel smooth.

You should use datastores to save the player’s stage. It won’t automatically save itself.

Yeah, I haven’t implemented this I’m going to get it later tonight. I’m just curious on if using a table to access spawn locations would be quicker than going into workspace and accessing it with the string.

You can use a dictionary.

local stages = {}
local x = 10 -- change with the amount of stages
for i = 1, x do
    stages[tostring(i)] = workspace['Stage '..i]

You can manipulate the dictionary to do anything you want with it.