Pre-requiring modules in a modulescript

Is this good practice or not? Figured it’ll save time.

return {
	["Damage"] = 45,
	["Self-Damage"] = 20,
	["Cooldown"] = 3,
	["ThisIsNotPassedToServer"] = 420, -- Ignore lol
	["HitBox"] = require(game:GetService("ReplicatedStorage").Modules.RaycastHitboxV4),
	["Engine"] = require(game:GetService("ServerScriptService").Modules.Engine),
	["Health"] = 60
}
---
local Main = require(Tool.Stuff)
local HitboxManager = Main.HitBox
local Engine = Main.Engine

I don’t see any issues with it. I think you can confidently believe that your practice is awesome.

1 Like

Thank you, figured out by accidentally using loadanimation in a dictionary table and it returns teh animation itself which saves a lot of time, then decided to do the same with modules

local Play:BindableEvent? = EventsFolder.PlayAnimation
local Animations:AnimationTrack? = {
	["kick"] = Animator:LoadAnimation(__ANIMATIONS.DoorKick),
	["dash"] = Animator:LoadAnimation(__ANIMATIONS.Dash),
	["fireattack"] = Animator:LoadAnimation(__ANIMATIONS.FireAxeAttack)
}
Play.Event:Connect(function(Animation:string?)
	if Animations[string.lower(Animation)] ~= nil then
		Animations[string.lower(Animation)]:Play()
	else
		warn(Animation.. " doesnt exist in table.")
	end
end)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.