How would i update a table when a variable is updated

so i have something like


local CashMultiplier = 1

local Raritys = {
	{"Money1", .33 * CashMultiplier},
	{"Money2", .03 * CashMultiplier}
}

i thought i could just change the cash multiplier later and whenevre i call the table it would be updated with the new amount but it keeps the 1

any way to update this table whenever cash multiplier is changed or do i gotta do somethign else

Hi!

Use meta-tables or setup a system that utilizes a custom signal module. If you look up these you’ll see that the first may be a little complicated for beginners, but it will pay off.

so would i have to create some sort of function whenever so that whenever cash mult is changed i have to edit / rewrite some of the table

Metatables are not needed for this.

What you could do is make a function that returns a new table of rarities based on a given parameter.

local function GetRarities(CashMultiplier)
	return {
		{"Money1", .33 * CashMultiplier},
		{"Money2", .03 * CashMultiplier}
	}
end
3 Likes

never thought of this, thanks for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.