younis2811
(RanD0m_333)
1
Hello everyone,
So I am trying to work on a stats system with a moveset. To be honest dont have a clear plan on how I am going to make it but I am trying it anyways.
I wanted to store a moveset to the player using a string value but I made table which cannot be stored in a string value. Like this
local MoveSets = require(script:FindFirstChild("MoveSets"))
local AbilityManager = {}
function AbilityManager:CreateNewInfo(player :Player)
local PlayerStats = Instance.new("Folder")
PlayerStats.Name = "PlayerStats";
PlayerStats.Parent = player
local Defense = Instance.new("IntValue")
Defense.Name = "Defense"
Defense.Parent = PlayerStats
local Offense = Instance.new("IntValue")
Offense.Name = "Offense"
Offense.Parent = PlayerStats
local Ability = Instance.new("StringValue")
Ability.Value = MoveSets.TestMoveset1
end
return AbilityManager
Now the Movesets:
local MoveSets = {
TestMoveset1 = {
{["Name"] = "Test1", ["Cooldown"] = 5, ["Input"] = "E"},
{["Name"] = "Test2", ["Cooldown"] = 5, ["Input"] = "R"},
{["Name"] = "Test3", ["Cooldown"] = 5, ["Input"] = "T"}
},
TestMoveset2 = {
{["Name"] = "Test1", ["Cooldown"] = 5, ["Input"] = "E"},
{["Name"] = "Test2", ["Cooldown"] = 5, ["Input"] = "R"},
{["Name"] = "Test3", ["Cooldown"] = 5, ["Input"] = "T"}
}
}
return MoveSets
I really need someone’ s thought and good opinions to correct me the right way if my structure is wrong and thank you very much!!
2112Jay
(2112Jay)
2
Your structure is correct. The only mistake was trying to store a Lua table in a StringValue. Store the lookup key instead. Give me a moment here..
ModuleScript MoveSets
--ModuleScript in ReplicatedStorage
local MoveSets = {
TestMoveset1 = {
{Name = "Test1", Cooldown = 5, Input = "E"},
{Name = "Test2", Cooldown = 5, Input = "R"},
{Name = "Test3", Cooldown = 5, Input = "T"}
},
TestMoveset2 = {
{Name = "Test1", Cooldown = 5, Input = "E"},
{Name = "Test2", Cooldown = 5, Input = "R"},
{Name = "Test3", Cooldown = 5, Input = "T"}
}
}
return MoveSets
ModuleScript AbilityManager
--ModuleScript in ReplicatedStorage
local MoveSets = require(script.MoveSets)
local AbilityManager = {}
function AbilityManager:CreateNewInfo(player)
local PlayerStats = Instance.new("Folder")
PlayerStats.Name = "PlayerStats"
PlayerStats.Parent = player
local Defense = Instance.new("IntValue")
Defense.Name = "Defense"
Defense.Parent = PlayerStats
local Offense = Instance.new("IntValue")
Offense.Name = "Offense"
Offense.Parent = PlayerStats
local Ability = Instance.new("StringValue")
Ability.Name = "Ability"
Ability.Value = "TestMoveset1"
Ability.Parent = PlayerStats
end
return AbilityManager
Useage
local MoveSets = require(ReplicatedStorage.MoveSets)
local set = MoveSets[player.PlayerStats.Ability.Value]
I did that quickly, so it may need some love..
younis2811
(RanD0m_333)
3
Thanks I will try to implement this and let you know if it worked but this seems like the most logical thing to do.
1 Like
system
(system)
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.