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

Help with GUI messages!?

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)

1 comment

0

Next time you ask something, give the output.

1 answer

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.

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