Hello, as you may see from the code listed below, I am making a Roblox "squid game" I wouldn't call myself the most experienced at Lua, though I am learning.
The problem is, I have a "module script" inside replicated storage with a function being called, this function is called "DollFunction()" calling this function which I have done and works fine, will cause the Doll to come "alive", e.g sound effects and so forth. The problem is I have a text label in a 'screen gui' that says the phrase "Red light" or "green light". -Default set to "green light". However, that can be easily changed using "text =" etc. Anyways the problem is, this text GUI will not show even though it is being called to, and sometimes breaks the actual doll module script. So I have it set to "if doll spin is playing then..." so when the Doll Spin sound is played from the Module script when the doll function is called, the GUI will appear, however that is not the case.
My code for the TextLabel, this is in the 'StarterGui, RedLightGreenLight, GameText, Script'
script.Parent.Visible = false -- Setting value to false if game.Workspace.DOLL_SPIN.IsPlaying then -- Checking if the sound is playing script.Parent.Visible = true -- Setting value to true to make the gui appear script.Parent.Text = "Red Light" wait(1) script.Parent.Visible = false -- Setting back to false else script.Parent.Text = "Green Light" end
Now moving on to the Module Script, this is located in replicated storage.
local PlayerFinish = true local DollFolder = game.Workspace["Red light, Green light"].Doll local DollSound = game.Workspace["Red light, Green light"].Sound_Doll local DollTurn = DollSound.DOLL_SPIN local DollAmbient = DollSound.DOLL_AMBIENT local PlayerFinish = true local DollTurn = game.Workspace["Red light, Green light"].Sound_Doll.DOLL_SPIN local module = {} local function DollFunction() repeat wait(5) wait(math.random(3,8)) DollTurn:Play() print("Doll Rotated") wait(4) print("Doll back to normal position") wait(math.random(5,8)) DollTurn:Play() print("Doll Rotated") wait(4) print("Doll back to normal position") until PlayerFinish == false end return DollFunction
The Function is called in a separate script, though there is no problem with that. Any help and an explanation why what is happening would be great.