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

How do I make a message appear when the first player enters the game?

Asked by
wjs3456 90
10 years ago

So I want it to announce that the round will begin soon when the first person enters that the round will begin soon, but when I try it out nothing happens in the game or output.

Here's my script

function RoundBegin() Instance.new(Message("The round will begin soon")) Wait(3) Message:remove() end

game.Players.PlayerAdded:connect(RoundBegin)

What did I do wrong?

1 answer

Log in to vote
1
Answered by 10 years ago

alot of places. First, when you Instance something, you have to make sure its the right classname, and then set the text property.

function round(player,text,time)
local m = Instance.new("Message",player.PlayerGui)
m.Text = text
wait(time)
m:Destroy()
end

game.Players.PlayerAdded:connect(function(player)
round(player,"The round will begin soon",3)
end)

this means as soon as a player joins, it calls a function and only does it when they join. However, if the PlayerGui doesn't load in time, it will error. I would say use WaitForChild(), but for some reason it won't let me use it on a player, so I suggest waiting on the character.

function round(player,text,time)
local m = Instance.new("Message",player.PlayerGui)
m.Text = text
wait(time)
m:Destroy()
end

game.Players.PlayerAdded:connect(function(player)
workspace:WaitForChild(player.Name)
round(player,"The round will begin soon",3)
end)
0
Oh cool thanks that makes sense :) wjs3456 90 — 10y
Ad

Answer this question