Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I've tried making a GUI which uses module scripts and it won't work. Can someone help?

I'm planning on creating an Admin GUI using module scripts however, I can't quite get the gist of it.. I've tried doing it first of all so when I press Alt + Q then it opens. But I just keep getting errors and I can't seem to find out how to fix it. Could someone do this for me and explain how they did it so when I try doing the rest of the GUI, I will understand what to do and what I did wrong.

Error: Players.xXTouchOfFrostXx.PlayerGui.Somnium:2: attempt to call field 'Open' (a nil value)

Script:

local ModuleScript = require(game.StarterGui.Somnium.ScreenGui.Open)
ModuleScript.Open()

ModuleScript:

local Module = {}

local parent = script.Parent
local Players = game:GetService("Players") 
local UserInputService = game:GetService("UserInputService") 
local Q = Enum.KeyCode.Q -- Key 1
local LeftAlt = Enum.KeyCode.LeftAlt -- Key2
local Player = Players.LocalPlayer
local Parent = parent
local GuiEnabled	
UserInputService.InputBegan:Connect(function(Input, GuiProcessed)


	if not GuiProcessed and Input.KeyCode == Q then
        local KeysBeingHeldDown = UserInputService:GetKeysPressed()

        for i = 1, #KeysBeingHeldDown do
            if KeysBeingHeldDown[i].KeyCode == LeftAlt then
                if GuiEnabled then
                    GuiEnabled, Parent.Enabled = false
--Off--
script.Parent.Frame.Visible = false
 else
                    GuiEnabled, Parent.Enabled = true, true	
	
	script.Parent.Frame.Visible = true
end
end
end
	end
end)

return Module

I've also never used module scripts before so hopefully, I can learn something new. :D

Thank you in advance.

1 answer

✓ Accepted answer

.Open() is never defined. You would type something like this to do so:

local Module={}
Module.Open = function(args)
-- Code
end
return Module

This discussion is preserved as it was. New answers, comments, and votes are closed.