Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[2] How to do text manipulation?

Hello!

I am trying to manipulate the text in my ROBLOX UI in Game as follows

Take the username clydedbeast647

I want the script to display on the textlabel: clyded********

Here is my code:

local Username = game.Players.LocalPlayer.Name
local Filter = '*'
local ExpandTo = (#Username >= 5 and math.random(3,#Username-1) or 3)
local Result = Username:sub(1,ExpandTo)..Filter:rep(7)

script.Parent.Text = "Welcome back " .. Result

It keeps producing a random amount of *, I don't know how to fix it.

1 answer

local Username = game.Players.LocalPlayer.Name
local Filter = '*'
local rand
if #Username-1 > 3 and #Username >= 5 then
	rand = math.random(3,#Username-1)
else
	rand = 3
end
local ExpandTo = rand
local Result = Username:sub(1,ExpandTo)..Filter:rep(#Username-ExpandTo)
script.Parent.Text = "Welcome back " .. Result

Fixed it, further details are on Wiki

This discussion is preserved as it was. New answers, comments, and votes are closed.