Hello. I am making a remake of Flood EScape 2 and I was wondering how tomake a number have a corresponding text. For example, one is easy. Here is my script so far:
if Difficulty.Value = 1 then TextName3.Text = Easy end
Here are the variables:
local Difficulty = game.Workspace.Lost_Forest.Settings.Difficulty local TextName3 = game.StarterGui.ScreenGui.TextName3
You can use a dictionary to define what each number means.
It would look like this:
Local names = { ["1"] = "Easy", ["2"] = "Normal", ["3"] = "Hard", }
You can easily get the value of your key like this:
TextName3.Text = names[Difficulty.Value]
You can use an array/table too if you are only using numbers to call a value.
The main problem with your script is on line 2, as "Easy" isn't a defined variable yet. You can also use an array to convert numbers into strings quickly without making 3 extra lines of code.
You can also use a function to actively change the gui's text.
Here's your edited code:
local Difficulty = workspace["Lost_Forest"].Settings.Difficulty local TextName3 = game.StarterGui.ScreenGui.TextName3 local DifficultiesArray = {"Easy", "Medium", "Hard", "Insane", "Crazy"} --Heres a tip!: You can replace "game.Workspace" with just "workspace". Difficulty.Changed:Connect(function() TextName3.Text = DifficultiesArray[Difficulty.Value] end)