Very bizzare bug
Replicated = game.ReplicatedStorage
Dictionary = {}
Fighters = {"Ryu", "Ken", "Chun Lee"}
-- Set default parameters for characters
DefaultStatistics = {
["MaxHP"] = 100,
["Walkspeed"] = 16,
["JumpPower"] = 50,
}
--Create the dictionary
for index, value in pairs(Fighters) do
Dictionary[Fighters[index]] = {
["Name"] = Fighters[index],
["Statistics"] = DefaultStatistics,
["Skills"] = {},
["Model"] = DefaultCharacter
}
end
Ryu = Dictionary["Ryu"]
Ryu["Statistics"]["Walkspeed"] = 50
Ryu["Statistics"]["MaxHP"] = 100
Ryu["Skills"]["Jab"] = {
["Displayname"] = "Dragon Rush",
["SkillName"] = "Jab",
["Input"] = "PrimaryFire",
["Damage"] = {2, 5, 15},
["Speed"] = 20,
["Dash Length"] = 2,
["Knockback"] = 100
}
print(Dictionary)
local GetData = {Dictionary}
return GetData
print(Dictionary) Returns…
["Ryu"] = â–Ľ {
["Name"] = "Ryu",
["Skills"] = â–Ľ {
["Jab"] = â–¶ {...}
},
["Statistics"] = â–Ľ {
["JumpPower"] = 50,
["MaxHP"] = 150,
["Walkspeed"] = 50
["Ken"] = â–Ľ {
["Name"] = "Ken",
["Skills"] = {},
["Statistics"] = â–Ľ {
["JumpPower"] = 50,
["MaxHP"] = 150,
["Walkspeed"] = 50
}
["Chun Lee"] = â–Ľ {
["Name"] = "Chun Lee",
["Skills"] = {},
["Statistics"] = â–Ľ {
["JumpPower"] = 50,
["MaxHP"] = 150,
["Walkspeed"] = 50
}
When this code executes, it correctly changes [“Jab”] for only the instance [“Ryu”][“Skills”]. That means it doesn’t set [“Chun Lee”][“Skills”] or [“Ken”][“Skills”] to have the value [“Jab”], only [“Ryu”].
However, it changes all instances of descendants of [“Dictionary”] to have [“Statistics”][“Walkspeed”] = 50 and [“MaxHP”] = 150, when it sohuld only effect [“Ryu”][“Statistics”]. I’m confused as to why this behavior happens.