local Cash = game.Players.LocalPlayer.Values.Cash
local Item = game.Players.LocalPlayer.Values.Paper
local MaxSold = game.Players.LocalPlayer.Values.RItemMax
local TimeWait = game.Players.LocalPlayer.Values.RItemTime
local CashName = Cash.Name
local SellingFor = 5
local N2Abbreviate = require(game:GetService("ReplicatedStorage").N2Abbreviate_Module)
while true do
wait(TimeWait.Value)
if Item.Value == 0 then
wait(40)
end
if Item.Value > 0 then
if Item.Value >= MaxSold.Value then
print(MaxSold.Value)
local NumberSold = math.random(1,MaxSold.Value)
RemoteEvent:FireServer(Item,NumberSold,CashName,SellingFor)
script.Parent.LastSold.Text = "Last Sold ".. NumberSold.." Sheets of Paper!"
script.Parent.LastSoldAmount.Text = "+$"..N2Abbreviate.Convert(NumberSold*SellingFor,"Advanced")
elseif Item.Value < MaxSold.Value then
local NumberSold = math.random(1,Item.Value)
RemoteEvent:FireServer(Item,NumberSold,CashName,SellingFor)
script.Parent.LastSold.Text = "Last Sold ".. NumberSold.." Sheets of Paper!"
script.Parent.LastSoldAmount.Text = "+$"..N2Abbreviate.Convert(NumberSold*SellingFor,"Advanced")
end
end
end
No because if Item.Value is 0 and Item.Value is less than MaxSold.Value then the elseif would still run causing an issue with math.random(1,0) where Item.Value would be 0.
i’d put a bunch of prints to debug the code, it could be possible that your client script initializes way faster than the server script can set the value to 20, it could be reading it weirdly, etc.