IntValue not printing the correct value

– Sorry if this is the wrong place to ask something like this, I’m extremely new to forums like this.

  1. What do you want to achieve? Keep it simple and clear!
    I want my script to read the IntValue.Value correctly after it changes. I want to know why my script isn’t working as intended, and how to fix it.

  2. What is the issue? Include screenshots / videos if possible!
    I have a folder named “Upgrades” copied into every player, in that folder is an IntValue named “inventorySize”. I have a script located in a part in the workspace, that, when activated by a proximity prompt, should print the value of this IntValue. This is the script I used.

proximityPrompt.Triggered:Connect(function(player)
	local inventorySize = player:WaitForChild("Upgrades"):WaitForChild("inventorySize").Value
	print(inventorySize)
end)

The issue is, say I set my IntValue to value 1 to start off with. I run the game and I trigger the proximity prompt, it prints value 1. When I change the IntValue to different number, like 2, while the game is still running, and then trigger the proximity prompt again, it still prints value 1. This doesn’t make any sense at all, my IntValue is 2, not 1.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried using a NumberValue instead of an IntValue. I’ve tried changing the IntValue manually using the Explorer. The script still doesn’t print the new value.

Edit: I have a localScript in Starter.Gui that reads the new value of the IntValue just fine.

Well the problem seems to be when you change the value without a server script or without going to the server and changing the value then it won’t actually change on the client thus printing the same value as it hasn’t changed on the server

Yeah, it was because it needed a serverscript to change the Intvalue, instead of me or a localscript. The localscript/serverscript barrier is so confusing. Thanks for the help, I would have just been really confused about this simple thing for ages otherwise.

1 Like