I want to automatically change a player’s outfit or cosmetics when they acquire a new race in my game.
The different races are currently stored in a ModuleScript and the player’s current race is saved using DataStore. Everything works so far, but I’m unsure on how to implement the logic for changing the player’s looks based on race and where I should be storing everything. I’m not asking for any scripts, I’m just a bit lost and would like some guidance.
Module should return a dictionary of all important information about the race. DataStore should contain just a single string - the key used to get the information from the module.
When a player’s character is added, find the cosmetic info from the module and apply it. For example
Module:
return {
["Elf"] = {
["Face"] = "rbxassetid://536525",
["AccessoryFolder"] = script.ElfAccessories
},
["Goblin"] = {
["Face"] = "rbxassetid://5234342323",
["AccessoryFolder"] = script.GoblinAccessories
}
Server script:
races = reference.to.modulescript
race = get_stored_race()
player.CharacterAdded:Connect(function(character)
local race = races[race]
character.Head.Face.Image = race.Face
-- blah blah blah apply accessories too
end)
1 Like