RichText is acting weird

Hey I have a problem, I do not know why the rich text changes back to normal text once the health goes down can anyone explain how to fix it so it stays as rich text?

I can’t help if you can’t show your code. :frowning:

1 Like

Try wrapping the value in the script like this… "<i>".. value .."</i>". If you can send the script, it would be easier to understand. :+1:

1 Like

local player = Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local text = script.Parent

local humanoid = character:WaitForChild("Humanoid")

humanoid.HealthChanged:Connect(function()

text.Text = string.format("%d/%d", humanoid.Health, humanoid.MaxHealth)

end)

check replies now, I added it.

Try doing what @BeamGoosty said, it italicizes the text, like how you wanted.

Try this…


local player = Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local text = script.Parent

local humanoid = character:WaitForChild("Humanoid")

humanoid.HealthChanged:Connect(function()

text.Text = “<i>“.. string.format("%d/%d", humanoid.Health, humanoid.MaxHealth) ..</i>

end)

Why not just include it in the format?

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local text = script.Parent

humanoid.HealthChanged:Connect(function()
    text.Text = string.format("<i>%d/%d</i>", humanoid.Health, humanoid.MaxHealth)
end)

doesn’t work :thinking: I have no idea why.

this doesn’t work either, it just says what the placement text says

Oops I forgot to close the string, sorry I was on mobile. Try this…


local player = Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

local text = script.Parent

local humanoid = character:WaitForChild("Humanoid")

humanoid.HealthChanged:Connect(function()

text.Text = “<i>“.. string.format("%d/%d", humanoid.Health, humanoid.MaxHealth) ..”</i>“

end)

hmm, it still isn’t working, I do not know what’s going on

What is it showing? Can you send a screenshot? Also, is RichText enabled?

1 Like

image

that’s the error that pops up.

Oh lol, replace the player variable with this:

local player = game.Players.LocalPlayer
1 Like

preciate it, ima get back to developing.

1 Like