Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Hey can someone help me figure out how to add a number to a value(Int Value)?

I want my Int value to go up one every 30 seconds while in a true do loop, but I don't know how to add a number to a value here is my script so far:


	local Wins = Instance.new("IntValue")
	Wins.Parent = leaderstats
	Wins.Name = "Wins"
	
	while true do
		
		--here is where I'm supposed to add to the int value but I don't know-how.
		
	end

Note: This is in a function.

2 answers

✓ Accepted answer

Here is the wiki for Variables https://developer.roblox.com/en-us/articles/Variables

You can look through there, and if that doesn't help here is a sample script

while true do
	Wins.Value = Wins.Value + 1 -- The value of Wins turns into the value of Wins + 1 (1+1 = 2, 2+1 = 3, etc...)
	wait(30)
end

--[[
OFF TOPIC
You can also do while wait(30) do
]]

2 comments

1

thanks I thought it was wrong since subtraction isn't the same

0

You're welcome, here is the link to the Operators wiki for more info: https://developer.roblox.com/en-us/articles/Operators

while true do
	wait(30.1)--extra 0.1 secs for processing, feel free to change it back depending on how long --it takes
	Wins.Value+=1

This discussion is preserved as it was. New answers, comments, and votes are closed.