So Im making a game and wanted a developer had joined script it worked with one person but not two. Can someone explain to me what I did wrong?
local Players = Game:GetService("Players") function PlayerAdded( newPlayer ) if newPlayer.Name == "GuardainDev, StevenzsDev" then local msg = Instance.new("Message", Workspace) msg.Text = "A Developer has joined the game." wait(6) msg:Destroy() end end Players.PlayerAdded:connect(PlayerAdded)
There are several things wrong with your code. I'll highlight them with comments. Here's the corrected code:
a = game.Players:GetChildren()--Better to use GetChildren, and it shouldn't be local either. m = Instance.new("Message") function DevMsg() --You had spaces in between the parentheses and the "NewPlayer", it is better to just have nothing in the parentheses --I've pretty much rewritten everything below this line for i,v in pairs(a) do if v.Name == "GuardainDev" or "StevenzsDev" then m.Parent = game.Workspace m.Text = "A Developer has joined the game." wait(6) m:Destroy() end end end game.Players.PlayerAdded:connect(DevMsg)
Basically, the script above runs the function DevMsg every time a player joins. When as player joins, the script runs through everyone in the Players and checks if their name is GuardainDev or StevenzsDev.
If this doesn't work let me know, though it should work.