Text updating fine, IntValue still 0

I’m having this issue with IntValues not updating properly at runtime on the client.


This is the text that’s updating fine. I click, and the number updates. Fantastic!


This is where the issue starts. My IntValue is parented to the text above, but the value refuses to update when I click.

Help?

Before I forget, heres the fixed script:

local player = game:GetService("Players").LocalPlayer

local cookiecon = script.Parent.CookieContainer
local bakerycon = script.Parent.BakeryContainer
local numofcookies = cookiecon.NumberOfCookies
local bakerytitle = bakerycon.BakeryTitle

local cookie = script.Parent.Parent.Cookie.Cookie
local value = numofcookies.Cookies

bakerytitle.Text = string.format("%s's bakery", player.Name)

local function format(number)
	local pre, mid, post = tostring(number):match("(%-?%d?)(%d*)(%.?.*)")
	return pre..mid:reverse():gsub("(%d%d%d)", "%1,"):reverse()..post
end
cookie.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		value.Value += 1
		if value.Value == 1 then
			numofcookies.Text = "1 cookie"
		end
	end
end)

value.Changed:Connect(function()
	numofcookies.Text = tostring(format(value.Value)) .. " cookies"
end)

Posting in the Scripting Support forum without giving your script is like taking a car to a mechanic and saying ‘fix it’.
You have go give us your script(s).

At first guess I’d say you aren’t reading the IntValue.Value properly.

lol completely forgot to give my script, slipped my mind, sorry!

local player = game:GetService("Players").LocalPlayer

local cookiecon = script.Parent.CookieContainer
local bakerycon = script.Parent.BakeryContainer

local bakerytitle = bakerycon.BakeryTitle
bakerytitle.Text = string.format("%s's bakery", player.Name)

local numofcookies = cookiecon.NumberOfCookies

local cookie = script.Parent.Parent.Cookie.Cookie
local value = numofcookies.Cookies

local function format(number)
	local pre, mid, post = tostring(number):match("(%-?%d?)(%d*)(%.?.*)")
	return pre..mid:reverse():gsub("(%d%d%d)", "%1,"):reverse()..post
end
cookie.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		value.Value += 1
		numofcookies.Text = tostring(format(value.Value)) .. " cookies"
		
		if value == 1 then
			numofcookies.Text = "1 cookie"
		end
	end
end)

this is the entire thing

sorry, which part of the script is not working?

edit: nvm didn’t read the post correctly sorry lol

Add a print(value) and see what its printing.

Why are you checking if value == 1??? Instances can’t be compared with integers so I think what you meant was value.Value there?

yeah I meant value.Value

it’s fixed now

image
okay thats weird

Is this value in a UI? If so the one in the server UI folder won’t be updating values. It will show up under your player UI.

1 Like

omg im blind lmao, completely forgot PlayerGui existed

thanks for the help! i’ve gotten everything fixed and arranged and all is working as intended.

1 Like