Localization script isn't working

I’m doing a commission for someone right now and i’m making a script that basically translates the text but it’s only working if my language is English. If I change it to French or spanish or Portuguese it doesn’t work for some reason.
code:

local texts = {
	["EnglishText"] = game.Workspace.EnglishText,
	["FrenchText"] = game.Workspace.FrenchText,
	["PortugueseText"] = game.Workspace.PortugueseText,
	["SpanishText"] = game.Workspace.SpanishText
}

local languages = {
	["English"] = function()
		texts["FrenchText"]:Destroy()
		texts["PortugueseText"]:Destroy()
		texts["SpanishText"]:Destroy()
	end,

	["Spanish"] = function()
		texts["EnglishText"]:Destroy()
		texts["PortugueseText"]:Destroy()
		texts["FrenchText"]:Destroy()
	end,
	
	["French"] = function()
		texts["EnglishText"]:Destroy()
		texts["PortugueseText"]:Destroy()
		texts["SpanishText"]:Destroy()
	end,
	
	["Portuguese"] = function()
		texts["EnglishText"]:Destroy()
		texts["SpanishText"]:Destroy()
		texts["FrenchText"]:Destroy()
	end
}

--TO fire the function do languages["English"]()
local LanguageCodes = {
	["English"] = "en-us",
	["French"] = "fr-fr",
	["Spanish"] = "es",
	["Portuguese"] = "pt"
}

if game:GetService("LocalizationService").RobloxLocaleId == ("en-us") then
	languages["English"]()
elseif game:GetService("LocalizationService").RobloxLocaleId == ("fr-fr") then
	languages["French"]()
elseif game:GetService("LocalizationService").RobloxLocaleId == ("es") then
	languages["Spanish"]()
elseif game:GetService("LocalizationService").RobloxLocaleId == ("pt") then
	languages["Portuguese"]()
end

Thanks to anyone that helps!
-Cats767_99

Still haven’t found the issue anyone know yet?

Could you put this at the end of your if statement at the end of the script

else
	pcall(function()
		print(game:GetService("LocalizationService").RobloxLocaleId)
	end)

and tell me what results you get?

Which if statement? I’m on my phone right now so I’ll have to test this in the morning.

This. just put it beneath the last elseif

1 Like

I have to test this in the morning. So i’ll let you know if it works.

1 Like

This is my script so far:

local texts = {
	["EnglishText"] = game.Workspace.EnglishText,
	["FrenchText"] = game.Workspace.FrenchText,
	["PortugueseText"] = game.Workspace.PortugueseText,
	["SpanishText"] = game.Workspace.SpanishText
}

local languages = {
	["English"] = function()
		texts["FrenchText"]:Destroy()
		texts["PortugueseText"]:Destroy()
		texts["SpanishText"]:Destroy()
	end,

	["Spanish"] = function()
		texts["EnglishText"]:Destroy()
		texts["PortugueseText"]:Destroy()
		texts["FrenchText"]:Destroy()
	end,
	
	["French"] = function()
		texts["EnglishText"]:Destroy()
		texts["PortugueseText"]:Destroy()
		texts["SpanishText"]:Destroy()
	end,
	
	["Portuguese"] = function()
		texts["EnglishText"]:Destroy()
		texts["SpanishText"]:Destroy()
		texts["FrenchText"]:Destroy()
	end
}

--TO fire the function do languages["English"]()
local LanguageCodes = {
	["English"] = "en-us",
	["French"] = "fr-fr",
	["Spanish"] = "es-es",
	["Portuguese"] = "pt-pt"
}
wait(5)
if game:GetService("LocalizationService").RobloxLocaleId == ("en-us") then
	languages["English"]()
elseif game:GetService("LocalizationService").RobloxLocaleId == ("fr-fr") then
	languages["French"]()
elseif game:GetService("LocalizationService").RobloxLocaleId == ("es-es") then
	languages["Spanish"]()
elseif game:GetService("LocalizationService").RobloxLocaleId == ("pt-br") then
	languages["Portuguese"]()
else
	pcall(function()
		print(game:GetService("LocalizationService").RobloxLocaleId)
	end)
end

The English function is ran even after I change my language to spanish. It also didn’t print when I ran it.