im working on a turn based tile game, similar to nic but i have no idea how to structure the abilities so that both the client and the server can see from the same cooldowns
this is an excerpt from my code
function unit.Spawn(player, unitName, gridPosition : Vector3, grid)
local self = setmetatable({},unit)
self.model = unitModel
self.stats = unitData.Stats
self.owner = player
self.grid = grid
self.position = gridPosition
self.abilities = {
}
return self
end
do i use values and change them accordingly, and have the client connect to each and every one of those values to see if the ability is usable?
or do i use remote events and send all the information required about the unit to the client and work it out from there, because its not strictly based on time, but turns
It’s really up to you. Both will achieve what you want to do. Personally, I’d suggest using RemoteEvents as that’d be a lighter solution. Everything would be stored in code and not have the overhead of Instances. Plus, with RemoteEvents you’ll always know exactly when your data actually updated[1], so you’ll be able to account for lag/desync far easier.
As another personal advice, you don’t need to send all the unit information at once. You can just send whatever values that have changed. You can even cut down on network traffic by not even sending the cooldown information server->client unless there’s a potential desync detected (e.g., a player trying to use an ability on cooldown). You can just have the client calculate cooldowns alongside the server. But if you think that’s unsafe or might lead to too much issue, it’s really your choice. Do full updates server->client unless you find you’re sending too much data.
[1]: I forgot at the time of writing that you can also just use the events that Values have, so this distinction isn’t very significant.