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

Developer has join script help?

Asked by 9 years ago

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)

0
line 04 - I think you should try "GuardianDev","StevenzsDev" instead of "GuardainDev, StevenzsDev" kudorey619 138 — 9y

1 answer

Log in to vote
4
Answered by 9 years ago

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.

Ad

Answer this question