I want to make a script where a message will appear on the screen if I (Djinous) join the game. There a simple way I can do that?
EDIT: Forgot the code I already tried. There's probably something wrong with this, but I don't have the knowledge to find out what.
function onPlayerEntered(nP) if nP.Name == "Djinous" then m = Instance.new("Message", game.Workspace) m.Text = "The Commander has joined the game." wait(3) m:remove() end) else end end game.Players.PlayerAdded:connect(onPlayerEntered)
I find it easier to make the function and connect it on the same line, it just makes more sense when you have a script which does multiple things and end up with a load of connection lines at the bottom.
This script 'broadcasts': "Player {PlayerName} has joined the game"
game.Players.PlayerAdded:connect(function(plr) local name = plr.Name msg = Instance.new("Message", game.Workspace) msg.Text = "Player "..name.." has joined the game" wait(3) msg:Destroy() end)
If you wanted to make it so custom messages appear for specific people, like in your question then you'd do;
game.Players.PlayerAdded:connect(function(plr) local name = plr.Name if name == "Djinous" then msg = Instance.new("Message", game.Workspace) msg.Text = "The commander has joined the game" wait(3) msg:Destroy() end end)
If this has answered your question please accept with the box on the right -> If it doesn't work (I didn't test this) then please do let me know and I'll fix it. Finally, if you want a better explanation please do ask!
This is NOT a request site.
But if you know how to code then just use PlayerAdded:connect(plr) and just use plr.Name
function var(plr) local p = Instance.new("Message", workspace) p.Text = (plr.Name .. " Has Joined!") wait(2) p:Destroy() end game.Players.PlayerAdded:connect(var)