This script is supposed to add points on the event and have them get multiplied by the value of the rebirth multiplier but it doesn’t add any points at all. It was working before I added the rebirth multiplier so I think it could be the way I defined the multiplier variable because I’m not totally sure how to define things that are in StarterPlayerScripts. It doesn’t give me any errors in the output so I’m not sure what’s wrong.
game.ReplicatedStorage.Remotes.Add.OnServerEvent:Connect(function(player)
if not debounce then
debounce = true
local currency = 'Points'
local multiplier = player:WaitForChild("PlayerScripts").Rebirth.Multiplier
local ammount = math.random(2,4) * multiplier.Value
player.leaderstats[currency].Value = player.leaderstats[currency].Value + ammount
wait(0.5)
debounce = false
end
end)
game.ReplicatedStorage.Remotes.Add.OnServerEvent:Connect(function(player)
if not debounce then
debounce == true
local currency = 'Points'
local multiplier = player:WaitForChild("PlayerScripts").Rebirth.Multiplier
local ammount = math.random(2,4) * multiplier.Value
player.leaderstats.currency.Value = player.leaderstats.currency.Value + ammount
wait(0.5)
debounce == false
end
end)
The problem isn’t in the currency variable it’s in either the multiplier variable or the amount variable where I multiplied it by the multiplier value.
Also note when setting debounce to true or false, make sure to use one equals sign.
This checks to see if debounce is false: (Not intended) debounce == false
This sets debounce to false: (Intended) debounce = false
You use one equal sign when you are defining a variable. When you are changing a boolean in a function from false to true or true to false, you use two of them.
local player = game.Players.LocalPlayer
local rebirths = player:WaitForChild("leaderstats").Rebirths
local multiplier = script.Multiplier
rebirths.Changed:Connect(function()
if rebirths.Value >1 then
multiplier.Value = multiplier.Value * 2
end
end)