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

BillboardGUI displays player's name and random word?

Asked by 8 years ago

So I made a script to make the random word, but I don't know how to make the script have the player's name in-front of it, any help would be appreciated..

local names = {
    Common = {
        "Chest Pain";
        "Abdominal Pain";
        "Broken Leg";
        "Broken Arm";
        "Headache";
    };
    Uncommon = {
        "Toothache";
        "Headache";
    };
    Rare = {
        "Foreign Object";
    };
}

local common,uncommon,rare = .6,.9,1
game.Players.PlayerAdded:connect(function(plr)
    plr.NameDisplayDistance = 0
    plr.CharacterAdded:connect(function(chr)
        local random = math.random()
        local gui = script.BillboardGui:Clone()
        if random >= 0 and random <= common then
            gui.TextLabel.Text = names.Common[math.random(1,#names.Common)]
        elseif random >= common and random <= uncommon then
            gui.TextLabel.Text = names.Uncommon[math.random(1,#names.Uncommon)]
        elseif random >= uncommon and random <= rare then
            gui.TextLabel.Text = names.Rare[math.random(1,#names.Rare)]
        end

        gui.Parent = chr
        gui.Adornee = chr:WaitForChild("Head")
    end)
end)

Answer this question