Hi there! I’m trying to make my clouds hide at a random time, and appear again at another random time and so on. I’ve started with this, but I’m now not sure what you do with the function :GetChildren()
My script is in a model, with all the parts named as cloud. I know its very simple but for some reason I can’t remember exactly how you lay it out.
Random is not a function, it’s a custom Roblox datatype that has a constructor function, Random.new, which returns a new Random object that has 2 methods, NewNumber and NewInteger, which return numbers based of the individual method called.
Your while loop should contain a wait call with the Random number to have random increments.
Now, for the GetChildren call, that method returns a table of the child instances of the instance it’s called on so you can iterate through the table and then set the Transparency property.
This is what your script should look like:
local WaitNum = Random.new():NextInteger(60, 120) -- Gets a new integer between 60 and 120 which we'll use for the wait call
while true do
for i,v in pairs(script.Parent:GetChildren()) do
v.ImageTransparency = (v.ImageTransparency == 1) and 0 or 1
end
wait(WaitNum)
WaitNum:NextInteger(60, 120) -- Generates a new number for the next loop iteration
end
Random.new():NextInteger is Roblox Lua’s version of Python’s randint function. math.random is also apart of Lua’s math library that can be called with no arguments and returns a random number between 0 and 1, can be called with 1 integer that will return a number 1 and above (inclusive), and 2 arguments that’ll return a random integer (inclusive) between the two arguments (integers).