Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Help with GUI messages!?

Asked by 6 years ago

Hello, I'm kinda "noobish" at scripting but could someone help with this script? I want it to make a new text box and GUI that greets the player when they enter the game. When I enter the game no GUI appears.

Thanks for reading, Leg0Brick

function onEnter(player) 


    repeat wait() until player.Character ~= nil     -- Wait for the player to spawn 
    local m = Instance.new("ScreenGui")
    local TB = Instance.new("TextBox")          -- Create a message
    m.Parent = StarterGui 
    TB.Text = "Hello, " .. p.Name .. "!"                -- Greet the player
    wait(10) 
    m:remove()                          

end 
game.Players.PlayerAdded:connect(onEnter)
0
Next time you ask something, give the output. Tesouro 407 — 6y

1 answer

Log in to vote
0
Answered by
Tesouro 407 Moderation Voter
6 years ago

You didn't define TB parent nor p. Also, you should clone directly to the PlayerGui, because StarterGui is for all players and it shows when the player respawn. It may look like this:

function onEnter(player)
    repeat wait() until player.Character ~= nil
    local m = Instance.new("ScreenGui")
    local TB = Instance.new("TextBox")
    m.Parent = player.PlayerGui
    TB.Parent = m
    TB.Text = "Hello, " .. player.Name .. "!"
    wait(10)
    m:Destroy() -- remove is deprecated
end 
game.Players.PlayerAdded:connect(onEnter)

And I think you should set the textbox size too, to look better.

Ad

Answer this question