simple problem but cant find the solution just like the title i want to change the “.” character to “:” character in this number value
while wait(0.0001) do
if game.Lighting:GetAttribute("DayOrNight") == "Day" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
script.Parent.Text = formatted.."Am"
elseif game.Lighting:GetAttribute("DayOrNight") == "Night" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
script.Parent.Text = formatted.."Pm"
end
end
I haven’t used string.gsub(), but I think this will work?
while wait(0.0001) do
if game.Lighting:GetAttribute("DayOrNight") == "Day" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
formatted = string.gsub(formatted, "%.", ":") -- Replacing "." with ":"
script.Parent.Text = formatted.."Am"
elseif game.Lighting:GetAttribute("DayOrNight") == "Night" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
formatted = string.gsub(formatted, "%.", ":") -- Replacing "." with ":"
script.Parent.Text = formatted.."Pm"
end
end
thats my script that has gsub and it changes the text to “:::::Am”
while wait(0.0001) do
if game.Lighting:GetAttribute("DayOrNight") == "Day" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
local changedchar = string.gsub(formatted, ".", ":")
script.Parent.Text = changedchar.."Am"
elseif game.Lighting:GetAttribute("DayOrNight") == "Night" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
local changedchar = string.gsub(formatted, ".", ":")
script.Parent.Text = changedchar.."Pm"
end
end
while wait(0.0001) do
if game.Lighting:GetAttribute("DayOrNight") == "Day" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
local changedchar = string.gsub(formatted, "%.", ":")
script.Parent.Text = changedchar.."Am"
elseif game.Lighting:GetAttribute("DayOrNight") == "Night" then
local formatted = string.format("%.2f", game.Lighting.ClockTime)
local changedchar = string.gsub(formatted, "%.", ":")
script.Parent.Text = changedchar.."Pm"
end
end
Some matching functions like string.gsub use pattern strings which have special “magic” characters that you might need to escape (like “.” in your case)