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)