i have 2 pieces of code, this:
--textscenes -- the file used to control the chat function _G.wt1 = false _G.wt3 = false _G["WelcomeText1"] = function() local p = game.Players:GetChildren() _G.openChat() for i = 1, #p do _G.showspacebarchat() p[i].PlayerGui.Chat.ChatWindow.ChatText.Text = "Welcome to Roblox Party!" _G.talkExcitedUltraTechX:Play() _G.talkExcitedValien:Play() end wait(0.25) _G.wt1 = true end _G["WelcomeText2"] = function() local p = game.Players:GetChildren() for i = 1, #p do _G.hidespacebarchat() p[i].PlayerGui.Chat.ChatWindow.ChatText.Text = "what board would you like to play on?" _G.talkExplainUltraTechX:Play() _G.talkExplainValien:Play() end _G.showBoardSelection(); end _G["WelcomeText3"] = function() local p = game.Players:GetChildren() for i = 1, #p do _G.showspacebarchat() p[i].PlayerGui.Chat.ChatWindow.ChatText.Text = "alrighty then, lets go to ".._G.board.." land".."!" _G.talkExcitedUltraTechX:Play() _G.talkExcitedValien:Play() end wait(0.25) _G.wt3 = true end _G["WelcomeText4"] = function() local p = game.Players:GetChildren() _G.closeChat() for i = 1, #p do _G.hidespacebarchat() _G.creategoToPortal() _G.enablegoToPortal() end end
and this file:
--keyhandler --modulescript code: local module = {} function module.onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.Space then print("Spacebar was pressed") if(_G.wt1 == true) then _G.wt1 = false _G.WelcomeText2() elseif(_G.wt3 == true) then _G.wt3 = false _G.WelcomeText4() end end end return module
this code works in studio, but not in the real game. Why is this not working? Thanks in advance.
There's two reasons this could be erroring, you'll need to add a WaitForChild or either you added something there that only localscripts can detect.