I’m new to module scripts but here’s the question:
Is there a way in a module script function to print one of the 2 strings?
Example wants to print only the first sting and not the second.
Module Script:
local module = {}
local function test()
print(“1”)
print(“2”)
end
return module
script:
local module = require(script.Parent.ModuleScript)
module.test()
function module:test()
if math.random() > 0.5 then
print("1")
else
print("2")
end
end
This implementation will PRNG a float in the range [0, 1), and based on what number is generated, it’ll either print 1 or 2. Basically, it’ll do a coin toss and pick one to print based on what it gets.
Don’t want to come off as rude, but how much programming experience do you have? I think you might want to take a step back and go over fundamental programming concepts first before trying to create a project.
First, you have to do function, not local function or else it won’t work. You can have a parameter for the string you want to print and print that that way.
Just concerned that you might be biting off more than you can chew, since I see plenty of people with the enthusiasm to make a game, only to turn around and get stuck by simple programming problems because they think they can get good enough at Lua to program a game in a single day.
I agree that I am not like that (without being enthusiastic about doing something), but I don’t think about all the possibilities, I may even know what to do but since I don’t think about everything, it is the result of being like that.