Best way to replicate module script to clients from server

I have a pet system in my game with each pet having their own module script holding all of their info (Rarity, name, etc.)
Because I want it to be accessed by both server and client, it becomes annoying when I change a value because it doesn’t replicate.
What is the easiest way to get around this?

Why store it in a module script in the first place? Just set attributes on the pet itself and you will be good to go.

There are plenty of values including tables of strings.

If that’s the case then you can just replicate the data from the server to the client using remote events. But other than that, attributes are your best choice to approach to your problem.

Remote events, ye. But how should I handle this, do I constantly fire a remote saying to update it?

But I’m working with tables

I think I can provide a better solution if you can tell me more of your main goal here.

Or you could convert those table of strings in to StrValues parented under a folder.

Can you show me a screenshot of how the table looks like?

Here is my module script currently:

local runService = game:GetService("RunService")

local finder = game.ReplicatedFirst.Pets
local remote = game.ReplicatedStorage.remotes.ReplicateModule

local pet = {}
pet.__index = pet

pet.Type = script.Parent.Name
pet.GivenName = "Red"
pet.Rarity = "Mythical"
pet.Damage = 0
pet.Multiplier = 1
pet.Enchants = {'POWER'}
pet.Extra = {}
pet.Powers = {}

pet.Powers.Angelic = false
pet.Powers.Demonic = false
pet.Powers.Warped = true

pet.Value = 100
pet.Equipped = false

pet.Damage = 1
pet.Attacking = false

function pet:AddEnchants(adding)
	for i,v in pairs(adding)do
		table.insert(pet.Enchants,v)
	end
end

function pet:RemoveEnchant(removing)
	local index = table.find(pet.Enchants,removing)
	if index then
		table.remove(pet.Enchants,index)
	end
end

function pet:Attack(Position)
	
end

return pet

It seems you are trying to apply the concept of OOP to create a pet system.

You have created it wrong because this is not how you are supposed to apply OOP. You can check out a good tutorial on how to do OOP here:

oops, thanks for the help, I’ll use remote events to get it done.

1 Like

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