Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This chat message involving random generated text isn't working. What do I do?

Asked by 6 years ago
local Letters =
 {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
bc = BrickColor.new("Really blue")

math.randomseed(tick())
game.Players.PlayerAdded:connect(function(Player)
    wait(1)
    local text = ""
    wait(1) 
    for i = 1,5 do
    wait(1)
        text = text..((((i/2 == math.floor(i/2)) and math.random(0,9)) or Letters[math.random(1,#Letters)]))..((i == 2 and "-") or "")
    end
    print("Working")
    a = text
end)

game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "[Arona] Hello Test Subject. Please go ahead and push the box in the hole to verify your humanity." + " Your Test Subject Recollection Name is : " + a;
    Font = Enum.Font.Arial;
    Color = bc.Color;
    FontSize = Enum.FontSize.Size96;    
})

Expectation : [Arona] Hello Test Subject. Please go ahead and push the box in the hole to verify your humanity. Your Test Subject Recollection Name is : (2 figures - 3 figures)

Tree: StarterPlayer StarterPlayerScripts LocalScript(Where this is ^^^)

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

You can't use + operator to concatenate strings. Instead, use ... Also, since it's a LocalScript, you don't need to use PlayerAdded

local Letters =
 {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
bc = BrickColor.new("Really blue")

math.randomseed(tick())
wait(1)
local text = ""
wait(1) 
for i = 1,5 do
    wait(1)
    text = text..((((i/2 == math.floor(i/2)) and math.random(0,9)) or Letters[math.random(1,#Letters)]))..((i == 2 and "-") or "")
end
print("Working")
local a = text

game.StarterGui:SetCore("ChatMakeSystemMessage", {
    Text = "[Arona] Hello Test Subject. Please go ahead and push the box in the hole to verify your humanity. Your Test Subject Recollection Name is : " .. a;
    Font = Enum.Font.Arial;
    Color = bc.Color;
    FontSize = Enum.FontSize.Size96;    
})

Ad

Answer this question