I am not looking for somebody to write anything. I just need to know how could I make a button in my game that changes the local user’s language.
This is probably in the wrong category
I am not looking for somebody to write anything. I just need to know how could I make a button in my game that changes the local user’s language.
This is probably in the wrong category
What do you mean by “changes the local user’s language”? Are you talking about changing the UIs text based on their language or something else?
What I mean is if somebody presses a button, instead of it being their default language, it would be spanish for example. I want to make a menu where you can change your language in my game without needing to go to your roblox settings.
local button = --Pathway for the button
local function translate()
button.Text == -- Translated text here
end
button.MouseButton1Click:Connect(translate)
I don’t think you can do it by auto generated (meaning you have to write the text your self)
Here is an example
local SpanishButton = -- your Spanish button location
local PlayButton = -- the Play button location or whatever
function ChangingToSpanish()
PlayButton.Text = "Play" -- I don't know how to speak spanish obv but you can use google translate if you want
end
SpanishButton.MouseButton1Click:Connect(ChangingToSpanish)
What do you mean by “use a translator for this” ?
Did my solution work?
are there any errors?
use a translator to convert all the words into spanish
Id probably just read through this, I don’t know if this is similar to what you’re looking for but it might help
first make a module w/ with the languages
local langmodule = {
english = {
"hello ",
"world!",
"english"
},
spanish = {
"hola ",
"mundo!",
"español"
}
}
return langmodule
now put a localscript w/ the button function
local lang = require() -- put the module direction on the "()" ex: require(script.langmod)
local languageid = 0 -- default (none)
local testbutton, changebutton = script.Parent.ButtonA, script.Parent.ButtonB -- this is a example but you can put other buttons
function checkem()
local transform = {[true]=1,[false]=0}
languageid = transform[(languageid<2)]+1 -- operative (true = 2, false = 1)
local current = lang[languageid]
changebutton.Text = current[3] -- updates the text
--[[
NOTE: you can simplify it
local transform = {[true]=2,[false]=1}
languageid = transform[(languageid<2)]
]]
end
checkem() -- update the langid state
testbutton.MouseButton1Click:Connect(function()
local current = lang[languageid]
print(current[1] .. current[2]) -- id[1]: hello world!, id[2]: hola mundo!
end)
changebutton.MouseButton1Click:Connect(checkem)
Seems like it would work but it will be super long. But oh well ig
I still don’t understand what you are trying to tell me.
Edit: I found this online: “Translator” is this what you mean?
Yeah, all you have to do is translate the text, then script the button so it changes into that translated text.