-
What do you want to achieve?
I would wish for my tycoon cash balance to continually increase with new players joining. -
What is the issue?
I have a tycoon kit which continually increases cash in a while wait(3) do loop. After testing in studio and finding that it all works, I have done a test launch and found a pretty major issue. The issue is that the cash is not being given to the collection spot (mailbox in this case). Upon first joining the mailbox will continually be filled with cash and it is not until older servers appear that the issue arises. After looking at the console, I have discovered a rather large error. I have linked an image of it below along with the snippet of code it is referring to.
(line 226 states the following: script.Parent.CashCollect.Value = script.Parent.CashCollect.Value + script.Parent.Income.Value)
-
What solutions have you tried so far?
I have wrapped the whole loop in a pcall function in the hopes that it would just run through the error, but it does not seem like that is the case. I looked for various solutions to my problem and found none.
while wait(3) do
pcall(function()
if script.Parent.Owner.Value ~= "None" then
local Player = game.Players:FindFirstChild(script.Parent.Owner.Value)
if Player then
if (Player and Player:FindFirstChild("InfiniteMailbox")) or (Player and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,10518526)) then
script.Parent.MaxHold.Value = 9e9
end
if script.Parent.CashCollect.Value < script.Parent.MaxHold.Value then
script.Parent.CashCollect.Value = script.Parent.CashCollect.Value + script.Parent.Income.Value
if (Player and Player:FindFirstChild("x2Cash")) or (Player and game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,10398126)) then
script.Parent.CashCollect.Value = script.Parent.CashCollect.Value + script.Parent.Income.Value
end
if script.Parent.CashCollect.Value >= script.Parent.MaxHold.Value then
Full = true
script.Parent.CashCollect.Value = script.Parent.MaxHold.Value
script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.TextColor3 = Color3.fromRGB(255,0,0)
else
Full = false
script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.TextColor3 = Color3.fromRGB(50, 255, 126)
end
script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.Text = "$" .. script.Parent.CashCollect.Value .. "/" .. script.Parent.MaxHold.Value
end
if Player then
game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("MailboxAnimation"):FireClient(Player,script.Parent.Essential.Mailbox,script.Parent.Income.Value,Full)
end
if Player:FindFirstChild("AutoCollect") or game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,10520087) then
local CashDataStore = DataStore2("Cash",Player)
CashDataStore:Set(Player.leaderstats.Cash.Value + script.Parent.CashCollect.Value)
script.Parent.CashCollect.Value = 0
script.Parent.Essential.Mailbox.CollectSpot.BillboardGui.Holding.Text = "$" .. script.Parent.CashCollect.Value .. "/" .. script.Parent.MaxHold.Value
end
end
end
end)
end