Hi all,
I’ve been developing a role playing sort of game, as a sort of a nice reintroduction to Roblox after a few years off.
Above is the set up of my workspace.
In said game, players control a character which is created using the “characterModule” script.
This script essentially creates a dictionary containing all sorts of info about said character, as seen below:
function char.createCharacter(name, age, nationality, ID) -- Function that creates variables and values for a character
local newCharDict = { -- Dictionary that stores the contents of our character, such as:
-- Basics
["Character Name"] = name, -- Character name
["Character Age"] = age, -- Character Age
["Character Id"] = ID, -- This is an ID which is unique to every character
["Character Nationality"] = nationality, -- Character Nationality
-- Traits and Personality These are Personality and Trait Objects
["Character Personality"] = {}, -- A table which holds the characters personality - These cannot be changed
["Character Traits"] = {}, -- A table which holds the characters traits - These can be changed
-- Basic Stats These are Integers
["Character Stats"] = { -- A table of character stats, whoch are influenced by their traits and personality
Marshal = nil, -- Ability to lead armies
StewardShip = nil, -- Ability to manage finances
Learning = nil, -- Ability to research
Diplomacy = nil, -- Ability to negotiate
Intrigue = nil, -- Ability to scheme
},
-- Physical Stats These are a variatey of values
["Character Physical"] = {
Height = nil, -- Integer, affects HeighScale of the physical Humanoid
Fat = nil, -- Integer, affects WidthScale and DepthScale of the physical Humanoid
Skin = nil -- Color3, affects the color3 of the physical Humanoid
}
}
return newCharDict -- Return the character so that it can be added to a dictionary
end
In the “worldCreation” script, these characters are created and added to a global table, alongside other bits and bobs required.
_G.charDict = {}
...
for i=1, 15 do
local newChar = characterModule.createCharacter(characterNamesMale[i], math.random(16,68), "Weslh", i) -- Create a new Character
_G.charDict[i] = {characterModule.createPhysicalCharacter(newChar, genChar), newChar} -- Create a physical representation of that character
end
I finally have some GUI. The aim is to click a button and to pick a random character, and display their stats.
There’s one small issue however - The GUI code is in a LocalScript.
My question therefore is how would i access the “charDict” dictionary in my LocalScript? or at least, what would be some pointers on getting it to work?
Thanks!