How to combine various values into a single one?

By this, I mean for example having 4 different NumberValues that equal 7, 5, 3, 8 and then a script gathering all of these and turning a fifth NumberValue into 7538.

I mean, you could try something like this. Probably more optimal ways but this is the first thing that came to my head. If anyone has a better method I’d recommend using that instead as this isn’t something I would personally want to use, just something quick that would work without looking too deep into it.

local FinalNumberHolder = workspace.mainNumber -- the numberValue where the numbers would show up
local NumberValueHolder = workspace.Folder -- ive opted that all of the numbervalues are in a folder of some sorts.
local EditingString = "" -- blank string 

for _, v in pairs(NumberValueHolder:GetChildren()) do
	if v:IsA("NumberValue") then
		EditingString = EditingString .. tostring(v.Value) -- edit the blank string to the number value

FinalNumberHolder.Value = tonumber(EditingString) -- set the final number value to the number

Heres what you’re looking for: What is table.concat() actually do?

Yep! Worked like a charm!

Thanks for helping too!

1 Like