Coins Multiplier not adding the 1.1

its not adding the 1.1 when i rebirth like if i would get 10 gems it should give me 11 with the 1.1

local CoinsAdded = 1 – Base amount of gems added per pickup
local RespawnTime = 0.5 – Time before the gem respawns
local Debounce = false
local PickedUp = false – Track if the gem has been picked up

script.Parent.Touched:Connect(function(touched)
if Debounce or PickedUp then
return
end

local Player = game.Players:GetPlayerFromCharacter(touched.Parent)
if Player then
	local Leaderstats = Player:FindFirstChild("leaderstats")
	local Coins = Leaderstats and Leaderstats:FindFirstChild("Gems")
	local Rebirth = Leaderstats and Leaderstats:FindFirstChild("Rebirth")

	if Coins and Rebirth then
		Debounce = true 
		local gemMultiplier = 1.1 ^ Rebirth.Value -- Calculate the gem multiplier based on rebirth count
		Coins.Value = Coins.Value + (CoinsAdded * gemMultiplier) -- Apply the multiplier to the base amount for each gem collected
		script.Parent.Transparency = 1
		PickedUp = true -- Mark the gem as picked up
		wait(RespawnTime)
		script.Parent.Transparency = 0
		Debounce = false 
		print("Rebirth count:", Rebirth.Value)
		print("Gem multiplier:", gemMultiplier)
	end
end

end)

Are you using an IntValue? If so, replace it with a NumberValue since that supports floats.

1 Like

Maybe try another way to increase it 10%:

local gemMultiplier = 1 + (0.1 * Rebirth.Value)
1 Like

unfortunately that didn’t work

sorry im not sure what you mean by this. still pretty new to all of this. i have each gem with there own script.

I meant like calculate the math in another way, if this might help.

1 Like

Is Rebirth a NumberValue or IntValue?
You can check this by selecting Rebirth inside the Explorer and looking in the Properties window, look for ClassName and if it says IntValue or NumberValue.

‘Integers’ and ‘Numbers’ are 2 different kinds of data. Integers are only whole numbers, so 1,2,3,4 …
‘Numbers’ can have decimals.

What could be the issue is that you’re trying to add a number onto an int, which I assume would round your addition away

1 Like

i dont see anything like that.

Oof, a script instance in every gem, good luck

there is not alot of gems yet i can still fix it. i kind of figured that was going to be a problem. how would i go about fixing that.

You should start with learning about module scripts. They let you put your code in 1 place, and ‘request’ it from anywhere.

1 Like

Thank you so much that’s was what i was looking for

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