What I am trying to do is get a certain word to appear in a different color than the rest of the text on a display board(part) and not a GUI.
(I put this script under the part that the player will touch to display their name.)
local Players = game:GetService("Players")
local text = game.Workspace.Display.SurfaceGui.TextLabel --the blank board's text
local db = false
local specW = {"TM11"} --special words
specW[1].Color = Color3.new(1,0,0) --making the color of the word red
script.Parent.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
local human = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if human then
if db==false then
db=true
if player.Name=="TibetanMastiff11" then
text.Text = "You are "..specW[1] --connecting the word with the sentence
else
text.Text = "False."
end
end
wait(10)
db=false
end
end)
How would I make a specific word from the text stand out on a display board(part)?
I’m pretty sure you can achieve this by using RichText, couldn’t you, or is that not what you’re looking for?
According to the information on RichText here, you could do the following: I want the <mark><font color="rgb(255,165,0)">orange</font></mark> candy. I’ve attached an image here just so you can see if that’s actually what you’re looking for.
if player.Name=="TibetanMastiff11" then
text.Text = "I want the <mark><font color="rgb(255,165,0)">orange</font></mark> candy."
else
text.Text = "False."
end
Try this instead, your script is getting confused because you’re using the same quotation marks for both.
if player.Name=="TibetanMastiff11" then
text.Text = 'I want the <mark><font color="rgb(255,165,0)">orange</font></mark> candy.'
else
text.Text = "False."
end
local Players = game:GetService("Players")
local text = game.Workspace.Display.SurfaceGui.TextLabel --the blank board's text
local db = false
local specW = {"TM11"} --special words
specW[1].Color = Color3.new(1,0,0) --making the color of the word red
script.Parent.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
local human = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if human then
if db==false then
db=true
if player.Name=="TibetanMastiff11" then
text.Text = 'I want the <mark><font color="rgb(255,165,0)">orange</font></mark> candy.' --connecting the word with the sentence
else
text.Text = "False."
end
end
wait(10)
db=false
end
end)
Here’s a few edits I made to get it to work! I was getting an error on the line specW[1].Color = Color3.new(1,0,0) which prevented it from running properly. Let me know if this works out for you now! Keep in mind this is just the edited script, there’s a couple things you no longer need in here as well as other things you should replace for best practice sake, but overall this is just an edit of your script!!
local Players = game:GetService("Players")
local text = game.Workspace.Display.SurfaceGui.TextLabel --the blank board's text
local db = false
local specW = {"TM11"} --special words
script.Parent.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
local human = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if human then
if db==false then
db=true
if player.Name=="TibetanMastiff11" then
text.Text = 'I want the <mark><font color="rgb(255,165,0)">orange</font></mark> candy.' --connecting the word with the sentence
else
text.Text = "False."
end
end
wait(10)
db=false
end
end)
Ah, strange! Glad it’s working now! Originally you wanted to text to be red, I’m sure you know how to make the text red with RGB values but just in case feel free to replace the line with font color rgb with “rgb(255,0,0)”!
local specW = {"TM11"} --special words
specW[1].Color = Color3.new(1,0,0) --making the color of the word red
This would result in the error attempt to index string with "Color".
You index the first item/element of the table named “specW” which accesses the string value “TM11”, you then attempt to index a key/field inside this string object named “Color” which results in an error.