I’m currently making a Button Simulator game and I’ve met some bugs one of them being the numbers kept decreasing by 0.01. I can’t seem to find any errors in my code. And I’m using Eternitynum for it. Any help is appreciated!
Server Script:
local eter = require(game.ReplicatedStorage.EternityNum)
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "Leaderstats"
local cash = Instance.new("StringValue", leaderstats)
cash.Name = "Cash"
cash.Value = 0
local multi = Instance.new("StringValue", leaderstats)
multi.Name = "Multiplier"
multi.Value = 0
local c = eter.convert(cash.Value)
local m = eter.convert(multi.Value)
while task.wait(0.3) do
if eter.eq(eter.convert(multi.Value), eter.convert(0)) then
c = eter.add(c, eter.convert(1))
else
c = eter.add(c, eter.mul(eter.convert(multi.Value), eter.convert(2)))
end
cash.Value = eter.bnumtoscientific(c)
end
end)
Button Script
local eter = require(game.ReplicatedStorage.EternityNum)
local pricetag = script.Parent.PriceTag.TextLabel
local rewardtag = script.Parent.RewardTag.TextLabel
local price = script.Parent.Config.Price
local reward = script.Parent.Config.Reward
local debounce = false
pricetag.Text = price.Value.." Cash"
rewardtag.Text = reward.Value.." Multiplier"
local function button(player, button)
if player then
if eter.meeq(eter.convert(player.Leaderstats.Cash.Value), eter.convert(button.Config.Price.Value)) then
local c = eter.convert(player.Leaderstats.Cash.Value)
local p = eter.convert(button.Config.Price.Value)
local m = eter.convert(player.Leaderstats.Multiplier.Value)
local r = eter.convert(button.Config.Reward.Value)
c = eter.sub(c, p)
m = eter.add(m, r)
player.Leaderstats.Cash.Value = eter.bnumtoscientific(c)
player.Leaderstats.Multiplier.Value = eter.bnumtoscientific(m)
end
end
end
local touching = false
script.Parent.Touched:Connect(function(hit)
touching = true
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
print(touching)
repeat
button(plr, script.Parent)
task.wait(0.25)
until touching == false
end
end)
script.Parent.TouchEnded:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
touching = false
end
end)
Eternitynum Module: