Transferring a IntValues data to another IntValue

My code isn’t working. I’m a starter coder experimenting with scripts.

local playersAlive = game.Workspace.PlayersAlive.Value

local playersInGame = game.Workspace.PlayersInGame.Value

playersInGame = playersAlive + playersInGame|

If you can help, thanks.

The problem is you are storing the old Value inside the local variable.
Always make the variable for the Instance (IntValue) and index the Value when you want to use it.

local Int = workspace.yourintvalue
local Int1 = workspace.yourint1
local Int2 = workspace.int2

Int2.Value = Int.Value + Int1.Value

You’re immediately getting the value, if you want to change the property, you need to reference the property directly. Right now you have it so it gets the value in the property and store it in a variable, all it’s going is just changing the variables currently. Simple fix

local playersAlive = workspace.PlayersAlive

local playersInGame = workspace.PlayersInGame

playersInGame.Value += playersAlive.Value

The last line functions as how you were doing it, but uses one less call and is shorter

1 Like

Thanks for your help! Ill fix it now.