This script is in a coin that once you touch it, it is supposed to give you a certain amount of coins, then destroy itself, which it does (mostly) correctly. But the problem is that when I tried to introduce a modifier to how much coins it gives me. It still adds to coins like it should, but when the game open the modifier starts at 1, and when I press a button it changes to 2. But the script isn't changing the "coinage" value to 2 also, it just stays at 1, I'm sorry if my explanation is a bit unclear, if you need clarification just ask me. Could someone explain why this doesn't work, and point me in the right direction? thanks in advance Here's my script:
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local value = player.leaderstats.coins.Value
local coinage = player.leaderstats.coinage12.Value
local num = math.random(1,2)
local luckynum = math.random(1,10)
if luckynum == 1 then
num = num + 1
end
local num1 = num * coinage
value = value + num1
script.Parent:Destroy()
end
end)
