Hiya Developers!
Here i have a script, which randomly selects a number then prints it the the output. How would i make it so once the number is printed, i can update a IntValue of a object?
Here is the script:
local randomVars = {1, 2, 3}
local randomVar = randomVars[math.random(#randomVars)]
print(randomVar)
randomVar = randomVars[math.random(#randomVars)]
print(randomVar)
Thanks!
Provided you have the IntValue
already set up, you could do something like this:
local IntValue = IntValueObjectHere
local randomVars = {1, 2, 3}
local function ChangeInt(Number)
IntValue.Value = Number
end
local randomVar = randomVars[math.random(#randomVars)]
print(randomVar)
ChangeInt(randomVar)
I didn’t work, this is what i received:

Here is the code:
local IsPlatformPicked = workspace.PlatformsList.Platform1.IsPlatformPicked.Value
local randomVars = {1, 2, 3}
local function ChangeInt(Number)
IsPlatformPicked.Value = Number
end
local randomVar = randomVars[math.random(#randomVars)]
print(randomVar)
ChangeInt(randomVar)
You have the Value
saved in this variable here, you just only need to reference the IntValue object and not the actual IntValue.Value property
local IsPlatformPicked = workspace.PlatformsList.Platform1.IsPlatformPicked --.Value (BEGONE)
local randomVars = {1, 2, 3}
local function ChangeInt(Number)
IsPlatformPicked.Value = Number
end
local randomVar = randomVars[math.random(#randomVars)]
print(randomVar)
ChangeInt(randomVar)
1 Like