false flag solution from earlier post, the solution I marked was for setting the base income only with natural growth and NOT the actual accumulation, since then I have removed the solution from the first topic and the topic is reopened
I’ve edited the second script so now it looks like this after a few failed solutions. The base income refuses to change when I claim a stud tile still, but I tried one edit that surprisingly resulted in the opposite - the accumulation surprisingly worked, but in reverse; instead of increasing when I claim tiles, it decreases from the maximum to zero income per second if I claim all tiles (since then i’ve scrapped that version)
If you’re wondering where I put the values in, they’re parented with TextLabels within StarterGui;
Is that normal or do I have to move them to ReplicatedStorage?
local coinsbalance = script.Parent.resourceframes.coinsframe.coinsbalance
local coinsbalancevalue = coinsbalance:FindFirstChild('coinsbalancevalue')
local persecondincomelabel = script.Parent.resourceframes.coinsframe.persecondincome
local coinspersecondincome = persecondincomelabel:FindFirstChild('coinspersecondincome')
local studsbalance = script.Parent.resourceframes.studsframe.studsbalance
local studsbalancevalue = studsbalance:FindFirstChild('studsbalancevalue')
local persecondincomelabel2 = script.Parent.resourceframes.studsframe.persecondincome2
local studspersecondincome = persecondincomelabel2:FindFirstChild('studspersecondincome')
local player = game.Players.LocalPlayer
local CollectionService = game:GetService("CollectionService")
basecoinsincome = ""
basestudsincome = ""
function naturalresourcesgain()
basecoinsincome = 1
basestudsincome = 1
while true do
wait(1)
workspace.SFXFolder.timebombtick:Play()
coinsbalancevalue.Value += coinspersecondincome.Value + basecoinsincome
coinsbalance.Text = coinsbalancevalue.Value
persecondincomelabel.Text = "+"..basecoinsincome + coinspersecondincome.Value.."/s"
wait()
studsbalancevalue.Value += studspersecondincome.Value + basestudsincome
studsbalance.Text = studsbalancevalue.Value
persecondincomelabel2.Text = "+"..basecoinsincome + studspersecondincome.Value.."/s"
end
for _, studtile in CollectionService:GetTagged("HighlightableTiles") do
local clickdetector = studtile:FindFirstChild("ClickDetector")
if studtile:IsA('Part') and studtile.Name == "4x4studtile" then
if studtile:GetAttribute("Ownership") == player.Name then
--coinsvalue.Value += studtile:GetAttribute("CoinsProduction")
--studsvalue.Value += studtile:GetAttribute("StudsProduction")
while true do
local newcoinspersecondincome = coinspersecondincome.Value + studtile:GetAttribute("CoinsProduction")
local newstudspersecondincome = studspersecondincome.Value + studtile:GetAttribute("StudsProduction")
local newcoinsincome = basecoinsincome + studtile:GetAttribute("CoinsProduction")
local newstudsincome = basestudsincome + studtile:GetAttribute("StudsProduction")
coinspersecondincome.Value = newcoinspersecondincome
coinsbalancevalue.Value = basecoinsincome + newcoinsincome
studspersecondincome.Value = newcoinspersecondincome
studsbalancevalue.Value += basestudsincome + newstudsincome
persecondincomelabel.Text = "+"..newcoinspersecondincome.."/s"
persecondincomelabel2.Text = "+"..newstudspersecondincome.."/s"
print("added")
return
end
elseif studtile:GetAttribute("Ownership") == "[nil]" then
print("not owned")
coinsbalancevalue.Value += coinspersecondincome.Value + basecoinsincome
coinsbalance.Text = coinsbalancevalue.Value
persecondincomelabel.Text = "+"..coinspersecondincome.Value.."/s"
studsbalancevalue.Value += studspersecondincome.Value + basestudsincome
studsbalance.Text = studsbalancevalue.Value
persecondincomelabel2.Text = "+"..studspersecondincome.Value.."/s"
else
print("the hell?")
end
end
end
end
naturalresourcesgain()
if the issue is in the first script with the clickdetectors (in the first post) you may include that as well
Can you explain what you’re trying to do in a nutshell? Also, whats the click detector variable for if u never use it? You can make the while loop run inside a task.spawn so it doesn’t interrupt other code
while true do
local newcoinspersecondincome = coinspersecondincome.Value + studtile:GetAttribute("CoinsProduction")
local newstudspersecondincome = studspersecondincome.Value + studtile:GetAttribute("StudsProduction")
local newcoinsincome = basecoinsincome + studtile:GetAttribute("CoinsProduction")
local newstudsincome = basestudsincome + studtile:GetAttribute("StudsProduction")
coinspersecondincome.Value = newcoinspersecondincome
coinsbalancevalue.Value = basecoinsincome + newcoinsincome
studspersecondincome.Value = newcoinspersecondincome
studsbalancevalue.Value += basestudsincome + newstudsincome
persecondincomelabel.Text = "+"..newcoinspersecondincome.."/s"
persecondincomelabel2.Text = "+"..newstudspersecondincome.."/s"
print("added")
return
end
Returning before the end of a while true ends the function completely, stopping the natural resource gain function from happening. I would recommend removing the while loop as the code will only run once anyway , and I think it should work
yea both the balance value and income per tick increased automatically (only the balance should increase automatically, the income per tick should only increase as more tiles are claimed