function onPlayerEntered(newPlayer)
local name = game.Players.StringValue:clone()Parent = newPlayer name.Value = newPlayer.Name
if name.Value == "CorvetteLegend" then --replace roperson with your name
local m = Instance.new("Message") m.Parent = game.Workspace m.Text = "CorvetteLegend is in the game" --same here wait(10) m:remove() end end
You should make your code into a code block. I'll rewrite a whole script for you here though, here ya go.
a = game.Players:GetChildren() m = Instance.new("Message") function onPlayerEntered() for i,v in pairs(a) do if v.Name == "CorvetteLegend" then m.Parent = game.Workspace m.Text = "CorvetteLegend has joined the game." wait(6) m:Destroy() else end end end) game.Players.PlayerAdded:connect(onPlayerEntered)
There are two issues with Slick's script. One being that a
never gets updated to the new list of players, it just remembers all the players that were in the server when the script runs. Second of all, you don't need to loop through each player when a new player joins, the player that joins is passed as an argument in the PlayerAdded
event. This is how I'd write it.
local Players = Game:GetService("Players") function PlayerAdded( newPlayer ) if newPlayer.Name == "CorvetteLegend" then local msg = Instance.new("Message", Workspace) msg.Text = "CorvetteLegend has joined the game." wait(6) msg:Destroy() end end Players.PlayerAdded:connect(PlayerAdded)