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

Why is this require module line stopping all my scripts?

I have this line of code that grabs a table from a module with all the variables i use in any script

however i took a break from studio, came back and everything suddenly breaks on that line of code, plz help.

there are no errors and the scripts that have it stop right at that line of code and doesn't go any further

this is the code -

vars = require(game:GetService("ServerScriptService").Modules.Settings).vars()

this is the vars function in the module -

local module = {}
--Gets Variables For All Server Scripts. (Avoids Repetition)
module.vars = function()
	local vars = {}
	vars.save_key = "9918-6210-9034-0196"
	vars.command_prefix = "/"
	vars.minute_reward_time = 60
	vars.data_que_delay = 6
	vars.data_retrys = 10
	vars.game_intermission = 10
	vars.gear_equipping_time = 10
	vars.wins_required_start = 3
	vars.wins_increase = 1
	vars.vip1_time = "Days"
	vars.vip2_time = "Weeks"
	vars.vip3_time = "Months"
	vars.time_table = 
		{
			"Seconds", 
			"Minutes", 
			"Hours", 
			"Days", 
			"Weeks", 
			"Months", 
			"Years"
		}
	vars.time_table.Seconds = 1
	vars.time_table.Minutes = 60
	vars.time_table.Hours = 3600
	vars.time_table.Days = 86400
	vars.time_table.Weeks = 604800
	vars.time_table.Months = 2590000
	vars.time_table.Years = 31536000
	vars.player_data_tables = 
		{
			"stats",
			"os_stats",
			"gears",
			"games",
			"settings",
			"bans",
			"codes"
		}
	vars.start_data = 
		{
			"Credits-100",--Number Of Credits
			"Tickets-25",--Number Of Tickets
			"Points-0",--Total Points In All Games Including Kills that Counted As Points Aswell
			"Kills-0",--Total Kills In All Games 
			"Wins-0",--Games Won
			"Rounds-0",--Games Played
			"Donations-0",--Total Donated (unlock fun commands for lobby at donation goals)
			"Admin-1",--Admin Level
		}
	vars.start_os_data = 
		{
			"VIP-0-0",--Time Since Purchased (os time), VIP Level 
			"Bonus-0-0",--Last Bonus (os time), Time Played (minutes)
			"Minutes-0-0",--First Join (os time), Total Minutes Played
		}
	vars.player_settings = 
		{
			"Sound_Effects_Volume-1",
			"Server_Music_Volume-1",
			"Player_Music_Volume-1"
		}
	vars.game_data_tables = 
		{
			"server_game_que",
			"player_game_que",
			"players_waiting",
			"players_playing"
		}
	vars.rs = game:GetService("ReplicatedStorage")
	vars.ss = game:GetService("ServerScriptService")
	vars.mo = vars.ss:FindFirstChild("Modules")
	vars.re = vars.rs:WaitForChild("Remotes")
	vars.settings = require(vars.mo.Settings)
	vars.game_handler = require(vars.mo.Game_Handler)
	vars.player_handler = require(vars.mo.Player_Handler)
	vars.commands = require(vars.mo.Commands)
	vars.lobby_gui = vars.lobby:FindFirstChild("Lobby_Gui")
	vars.lobby_message_display = vars.Lobby_Gui:FindFirstChild("Lobby_Message").Display
	return vars
end

4 comments

0

basicaly vars is a function in the module that returns a table of variables

0

can you show the vars function so we can see what it does?

0

yes

0

there

1 answer

Vars is a function inside the module, which you are calling from the require. However, you're trying to set a variable equal to a function, which isn't possible. Instead, change vars to

local vars = require(game:GetService("ServerScriptService").Modules.Settings)

and then whenever you need to use the function, call

vars.vars()

1 comment

0

but im using a return value to set it to a table instead

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