Hiya guys. couldnt really find much on storing strongs n such. Im making a skill system for save, where your skillss are saved to a table or string.
like
local skills = ("swordfighter","HeavyTraining","DoubleJump")
should i do this, as a string or table?
and if i do do it as a string.
how would i check for specific skills?
if PlayerData.Skills.Value:Find("HeavyTraining") then
if its a simple game you can use strings, and use JSONDecode and JSONEncode for strings, JSONEncode converts a table into string which you can save, and if you want to easily access it in table form, use JSONDecode it will convert a string into a table
I would stick to tables, if you do want to go the route of using strings you can do what @meet_theHAXER said and use HttpService to encode and decode the table. However this isn’t really necessary and I don’t really see any reason to be using strings if not needed.
Table Example:
--> How the table would look
local Skills = { "Skill1", "Skill2", "Skill3", ... }
--> How you would check if a specific move exists
if table.find(Skills, "Skill1") then
--> Has Skill
else
--> Doesn't have skill
end
If you are planning on using HttpService to encode and decode it would pretty much be the same thing except you would have to encode the table first and then decode it after, like this:
local HttpService= game:GetService("HttpService")
local Skills = { "Skill1", "Skill2", "Skill3", ... }
--> Making it a string
local EncodedSkills = HttpService:JSONEncode(Skills)
print(EncodedSkills) --> prints ["Skill1","Skill2","Skill3"]
--> To make changes, you have to decode, make changes and encode again
local DecodedSkills = HttpService:JSONDecode(EncodedSkills)
table.insert(DecodedSkills, "NewSkill")
HttpService:JSONEncode(DecodedSkills)
If you want to strictly use strings then you could look into string manipulation using the string methods.