I am trying to create accessories with unique abilities that affect the user, but i am unsure how to go about it. I had an idea of just sending every piece of data from the client through and only use the ones necessary for that accessory but that is too complicated. i am just completely unsure how to make a unique ability for each class whilst keeping the code concise for later additions or reuse.
#Accessories being universally managed
1 messages · Page 1 of 1 (latest)
** You are now Level 1! **
Alright, could you explain the context? What types of accesories and abilities? Is it handled on the client or server? What should happen when?
Also, do you have any code yet, or are you just looking for advice?
i am just looking for advice, not necessarily for someone to write it for me but for the way i should go about it because i have no idea how i should make it. the accessories are like things that would make you run faster, or give you a second jump, or an ability to summon things. think terraria accessories.
my issue is finding a way to make the accessories unique without having a conditional for each one (example of conditional: if (accessory == "jump boots") then
humanoid.jumpheight = 9)
One way of doing this is having for example a module script that would return a table of functions, where the key of each function would be the name of the accesory. Then add the player as an argument to all functions and execute them on the server by requiring the module in a server script and executing the function by doing something like module[accesory](player)
Module example:
local module = {}
function module.JumpBoots(player)
print(player, "has equipped jump boots")
end)
return module
Server example:
local module = require(game.ReplicatedStorage.Modules.AccesoryFunctions)
local onAccesoryEquip = game.ReplicatedStorage.Remotes.OnAccesoryEquip.OnServerEvent
onAccesoryEquip:Connect(function(player, accesory)
module[accesory](player)
end)
OnAccesoryEquip is a remote event in a folder in replicatedstorage called ‘Remotes’ and module is in a folder in replicatedstorage called ‘Modules’
Does this make sense?
this concept seems like it should work well with what i am trying to accomplish, thanks for the help!