How can I set different audios depending on the country?

hello and good morning. I have a question, problems and etc. about user localization and etc.

Idea :bulb:


the idea of this script is simple but to make it at least for me is complex. What I want to do is “variation” of audios depending on the region of the user (in short, audios of characters will be translated).
my goal is that the game will have these audios available in portuguese, spanish and english. i already have the audios and all the stuff, i tried to make a simple script to give the idea.

Script :memo:



local audios = {
  ["portugues"] = "0000",
  ["espanol"] = "00000",
  ["ingles"] = "00000"
}


function onTouched(part)

  local idiom = game.Players.LocalPlayer.Locale.LanguageCode


  part.Audio = audios[idiom]
  part.Audio.Playing = true
end


script.Parent.Part.Touched:Connect(onTouched)

even so, it still shows errors in some things and I want to polish this, unfortunately I don’t have time to investigate well in the roblox documentation, anyone who can help me?

1 Like

Did you know there’s a service called LocalizationService?

There’s a function in there known as GetCountryRegionForPlayerAsync. I didn’t realise roblox stored that type of information.

3 Likes