Note: Done some mild erratic posting about this recently as I seem to begin realizing I have no idea what I’m undertaking as I’m confused about where to begin. What I want to make is a script which allows player cooldowns, damage, defence and so on to change if they get hit by other players, upgrade skills and so on.
If this doesn’t make much sense, please quickly read: How would I handle dynamic modifiers such as cooldowns, damage, defence etc? - #4 by benpinpop as I asked a question here before I started on the module scripts that I believe I do a better job of explaining this in. I hope this post makes sense by itself though.
Key
When I refer to “the module script” or any variant of “module script” I mean a module script which contains functions, stats for the player(damage, defence, cooldowns) and so on which can be accessed outside of the module script. This is cloned when the player joins, placed under a folder in serverstorage and named after them. Whenever I say a player “gets the module script” I mean they’re either getting their own stats from the module script or getting the opponents stats.
The template looks like this:
When I refer to “Local script” I mean the local script that when F is pressed it’ll get the text of the text box the local script is parented to. So for example, if I were to type in “Sxdistical”, Sxdistical would be the target and the player because Sxdistical pressed F and Sxdistical is the name stored in the text box as well.
Module Script
local PlayerStats = {}
PlayerStats.Stats = {Damage = 10, Defence = 10}
PlayerStats.Debuffs = {
-- Debuffs will be stored here with information on the debuffs,
-- this will be for cosmetic purposes - I'll create a server-side folder
-- which will contain all of the required information in regards
-- to what the debuff does I.E a folder named "Corrosion", with another one called "Stack"
-- and set to false.
}
PlayerStats.Buffs = {
-- Same as debuffs but positives instead of negatives.
}
function PlayerStats.Damage(Player, Target)
-- This would calculate the damage dealt to the player.
end
return PlayerStats
I restarted my script but the more I made this the messier and the more unusual in appearance it became.
The way I decided to handle my dynamic systems was a module script - for testing purposes I set up a local script which is stored in PlayerGui underneath a text box. When you press F it searched game.players for the text, so if it was “Sxdistical” it would look for game.players.Sxdistical then it would pass that value through the remote event.
The remote event connects to the server, then the server script will require the module script and get values from the module script - it’ll start by getting the damage and buffs/debuffs of the player who is attacking and then find the module script of the player who is being attacked by them and get their buffs/debuffs, defence as well as their current health.
After that it’ll calculate all of those to output damage which it will apply to the players health(as well as any debuffs if applicable).
This is meant to make it so I can change a players cooldown to cut it in half or double it, decrease their damage or check that they have no defence left and apply damage to their health all stored inside the module script.
I’m beginning to believe a module script is not the most efficient way, despite the question I asked here:
So, how would I handle dynamic stats? Am I going about it the wrong way with the module script method or is there an entirely different way I’m ignoring? I’m really struggling here.