Hello there, i wanna create a function that the size of the textlabel get changed on the amoun of letters in a word. (PlayerDisplayName) or (Rank Title) it would be realy helpfull if someone could help me.
but i need to say i dont wanna make the textlabel bigger then 0.75, 0, 1, 0 - and yes i want to use scale and not offset, also i use Scaled Text. So i dont want to use the automatic scale function bc it sucks.
So what i tried is something like this:
local textlabel = script.parent
local maxwidth = 0.75
local char = script.parent.parent.parent.parent -- getting the char of the player (overhead gui)
local player
if char then
player = game.Players:GetPlayerFromCharacter(char)
end
if player then
textlabel.Text = player.DisplayName
local maxlength = 20 -- a player name will never be longer then 20 letters.
local ratio = #textlabel.text/maxlength
textlabel.Size = Udim2.new(-0.25 + ratio, 0, 1, 0)
end
Alright guys i did it, if someone had the same problem, then i appreciate i could help. (its simple math)
local gui = script.Parent
local main = gui.Main
local rankholder = main.RankHolder
local ranktext = rankholder.RankText
local infoholder = main.InfoHolder
local level = infoholder.Level
local name = infoholder:WaitForChild("Name")
local paragon = infoholder.Paragon
local hb = main.Healthbar
local clipper = hb.Clipper
local top = clipper.Top
local char = gui.Parent.Parent
local player
local ranks = {
[255] = "[ Owner ]",
[254] = "[ Owner ]",
[253] = "[ Administrator ]",
[252] = "[ Moderator ]",
[251] = "[ Developer ]",
[250] = "[ QA Tester ]",
}
if char then
player = game.Players:FindFirstChild(char.Name)
end
if player then
name.Text = "NameWith20Letters123"
local ratio = #name.Text/20
name.Size = UDim2.new(0 + (0.75*ratio), 0, 1, 0)
end
local function updaterank()
if player then
rankholder.Visible = true
ranktext.Text = ranks[player:GetRankInGroup(6073791)]
local ratio = #ranktext.Text/17
ranktext.Size = UDim2.new(0 + (0.5 * ratio), 0, 1, 0)
warn(ranks[player:GetRankInGroup(6073791)])
end
end
updaterank()