Component system

Im making a component for the first time and im curious on how I should handle the client functions for each component.

what would be the best way to store client specific functions for the crate component?

I don’t take this exact approach but since im fairly new to this structure keep that in mind,

before I continue how does the crate work is it a player owned thing or something that could spawn…?

You know the eggs in simulators? Basically just that. I plan on having the crate opening animation and any other visual effects in a client script while the server one handles the purchase and stuff

Oh ok in that case what I’d do is:

1.) Create a Serverside module called EggsService

  • Handles rarity of egg hatching
  • Intializes type of egg and establishes connections

2.) Create a Clientside module called EggsController

  • Handles client sided animations and tweens by firing signals to server and receiving responses
  • I put my Controller names modules in a folder under StarterPlayerScripts

That’s how I’d do it, by the way what does Component Loader do?

1 Like

basically a module loader that loads every component in the game.

function Handler.Init()
	for _, mod in ComponentsFolder:GetChildren() do
		if not mod:IsA("ModuleScript") then continue end
		
		local comp = require(mod)
		Loaded[mod.Name] = comp
	end
	
	for _, tag in Tags do
		local module = Loaded[tag]
		
		if module.Init then
			for _, object in CollectionService:GetTagged(tag) do
				task.spawn(module.Init, object)
			end
		end
	end
end

But I think imma restructure the game into a series of services to make everything cleaner and less bloated

1 Like