Max value doesnt work

while true do
	print(food)
	wait()
end

Did you include this?

ohh im stupid wait i will add the code

still not work yet is still stuck on 10

The code was not meant to fix it, only to help us understand what might be causing the error. What does the output say?

theres no error in the output i dont know why

1 Like

its just say Foods and infinite yeld of my shop system

1 Like

Most bugs that people find do not show up in the output. The ones that do are very easy to fix, and are mostly silly errors. By littering prints throughout your code, you can help to determine the problem by analysing the data that is being printed. Can you please send a screenshot of the output when you play the game?

2 Likes

Sorry, my bad - replace:

print(food)

with:

print(food.Value)

I see the problem now. There is nothing wrong with the max value script, and that is working perfectly. The problem lies in the remote event that causes the food value to change. This is why it took me so long to figure the problem out. The remote event is being fired way more than you want it to, and so is reaching the value of 10 in mere seconds, being constrained and therefore “stuck” to that number. Can I please see the local script that fires game.ReplicatedStorage.AddPoint?

script.Parent.Activated:Connect(function()
game.ReplicatedStorage.AddPoint:FireServer(1)
end)

Now we’re tracing the issue back to the root cause - the parent of this script is being activated too frequently. What is this script parented to?

its parented to a tool

The activated event seems to be getting fired too often. Can you change your code to this:

script.Parent.Activated:Connect(function()
print("Activated")
game.ReplicatedStorage.AddPoint:FireServer(1)
end)

See if the phrase “Activated” is being printed just as frequently as the numbers

1 Like

Would you be happy adding me to the game via Team Create? It will be easier for me to analyse everything, rather than constantly asking questions and making suggestions. It’s all good if you don’t want to, however.

okay i will add you to my game team create

local max = 0
max = Max.Value
Max.Changed:Connect(function()
max = Max.Value
end)

its not working why this is so hard