Last active
July 10, 2022 00:32
-
-
Save mrsprinkler/b81f8412fbf5de031fcddd5d4eef5ea8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Textbox = script.Parent | |
local service = game:GetService("HttpService") | |
local jjson = '[{"text":"Hello","bold":"true"},{"text":" World","bold":"true"}]' | |
local LastJson = '' | |
local function convert(json) | |
local s,r = pcall(function() | |
service:JSONDecode(json) | |
end) | |
if s then | |
local DecodedJson = service:JSONDecode(json) | |
local XLM = "" | |
if DecodedJson[2] then --Many text | |
for i,Table in next,DecodedJson do | |
local Text = Table["text"] | |
local root = Text | |
print(root) | |
for property,value in next,Table do | |
print(property,value) | |
if property == "color" then | |
root = '<font color="'..value..'">'..root..'</font>' | |
end | |
if property == "UnderLined" and value == "true" then | |
root = '<u>'..root..'</u>' | |
end | |
if property == "Italic" and value == "true" then | |
root = '<i>'..root..'</i>' | |
end | |
if property == "bold" and value == "true" then | |
root = '<b>'..root..'</b>' | |
end | |
end | |
XLM = XLM..root | |
print(root) | |
end | |
else | |
local Text = DecodedJson["text"] | |
XLM = Text | |
print("Text = "..Text) | |
for property,value in next,DecodedJson do | |
if property == "color" then | |
print("Color is getting defined") | |
XLM = '<font color="'..value..'">'..XLM..'</font>' | |
end | |
if property == "bold" and value == "true" then | |
print("ran") | |
XLM = '<b>'..XLM..'</b>' | |
end | |
end | |
end | |
return XLM | |
else | |
return false | |
end --if s | |
end | |
Textbox.FocusLost:Connect(function(bool) | |
if bool then | |
local r = convert(Textbox.Text) | |
if r then | |
LastJson = Textbox.Text | |
Textbox.Text = r | |
end | |
end | |
end) | |
Textbox.Focused:Connect(function() | |
if LastJson ~= '' then | |
Textbox.Text = LastJson | |
end | |
end) | |
print("Script was created by mrfrinkler") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment