Some games have scripts, where certain attacks can increase your damage dealt temporarily, decrease/increase your defence. I was wondering how I would go about implementing this for my own game as I plan on having something very similar.
Idea 1 - Module Script
Have a module script containing the player’s damage, cooldowns for their abilities, and any other dynamic variables(could be a table listing each ability and its cooldown as well as other variables, abilities can be removed if the conditions for the ability are no longer met)
This way I could have a server-script accessing each of these variables in order to temporarily increase them, the server script will clone the module script to ServerStorage on player join and be able to temporarily decrease the variables, the module script will be named after the player i.e “Sxdistical”. Saving can be handled by saving the modules data and then loading by just cloning a template module and then reassigning the data to the cloned module on player join.
I.E
Local PlayerName = "Name of the player here"
req = require(game:getservice("ServerScriptService"))
Idea 2 - Editable variables stored inside ServerStorage(folder & subfolder)
Whereas my 2nd method is having integer variables, bools etc stored inside a folder named after the player I.E “Sxdistical” and then creating a separate subfolder for each power and inside each subfolder I will store their cooldowns, whilst the main folder named after the player will contain damage, defense and so on and these can very easily be altered by a script when needed. For example:
local Playername = NameOfPlayer -- will be assigned through a player join event
local PlayerStats = game:getservice("SevrerStorage"):WaitForChild(PlayerName) -- A folder stored in ServerStorage
local Damage = PlayerStats.Damage -- A damage integer
local Ability1 = PlayerStats.Ability1 -- The name of the ability is "Ability1",
-- would be referenced by the ability's script
local Ability1.Cooldown = Ability1.Cooldown/2 -- Will halve the cooldown
I’m wondering if anyone can confirm if these ideas would work, are flawed fundamentally, missing some thought or if they have entirely new ways I could implement them.
I do not want a script unless used as an example. I want this to be my own creation. I am looking for ideas.
If anything is not understood here just ask me to elaborate and I’ll elaborate, I tried to be as specific as possible whilst keeping it understandable and concise.
Honestly I’m not 100% sure this is meant to go here and will respectfully move it to the appropriate category if asked (the only one I can think of it being appropriate for is Game Design Support)