How can I compare an between an Object's Name and an IntValue (both being numbers)

Hello so basically, I have an obby game and It saves data and stuff, when you claim the checkpoint it has a tween that turns it green, now i wanna make it so that when you rejoin the checkpoint stays green. I tried to look this up but couldn’t find anything. I tried to use :match() but the realized it wont work. Pls help and thanks :+1:

P.S. the object name (or basically the checkpoint) is a number.

Something like this

object.Name == tostring( intValue.Value )

or this

tonumber( object.Name ) == intValue.Value

ok lemme try that real quick…
(char limit)

Yeah that doesn’t work idk why it doesnt print anything on the output either.

how are you storing data right now? Are you storing what level they are on?

idk but maybe u can show us the code so we can see whats wrong

if this is the case, just do a for loop on the client

for i = 1, TheirLevel do
     workspace.Checkpoints[tostring(i)].Color = -- whatever color here
end
1 Like

Try to print the results of the code he has provided you with as they are working conditions, perhaps you’re using them incorrectly?

You could also do this, just replace the code inside of the for loop with your tween function.

my power went off for a long time, sorry i didnt respond

yes i do store their data, pretty obvious.

i was asking how you were storing their data

what do u mean by that? its just your average setasync data store

like are you doing

local plrData = {
Level = 100,
}

or something like

local plrData = {
UnlockedLevels = {}
}

second one.
(annoying char limit so annoying)

can you print out your data and send me a screenshot of the table opened

You haven’t shown much code that we can use to determine what kind of issue you’re having. That said, I have created a small demonstration on how you can save / load stages. This is only an example, but feel free to reference off of it.

local CheckPoints = workspace.CheckPoints
local Data = game:GetService("DataStoreService"):GetDataStore("Checkpoints")
local DisplayGreen = game.ReplicatedStorage.Remotes.DisplayGreen

local function loadCheckpoints(Player)
	local checkPoints = Data:GetAsync(Player.UserId)
	if checkPoints then
		DisplayGreen:FireClient(Player, checkPoints)
	end
end

local function saveCheckpoints(Player)
	local savedCheckPoints = {}
	for i,v in pairs(CheckPoints:GetChildren()) do
		if tonumber(v.Name) <= Player.leaderstats.Stage.Value then
			savedCheckPoints[v.Name]=true
		end
	end
	Data:SetAsync(Player.UserId, savedCheckPoints)
end

game.Players.PlayerRemoving:Connect(saveCheckpoints)

for i,v in pairs(game.Players:GetPlayers()) do
	task.spawn(function()
		loadCheckpoints(v)
	end)
end
game.Players.PlayerAdded:Connect(loadCheckpoints)