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

PlayerAdded, ChatMessage help?

Asked by 8 years ago

So, I'm trying to make a script that when a player joins that is on the "whitelist" (called specials) a chat message shows up. --Shouldn't be too hard to explain @CailThePuppy

PROBLEM Nothing happens, nor does the things print

local specials = {"rexbit", "TheHospitalDev","Player","Player1"}

game.Players.PlayerAdded:connect(function(player)
    print("Hola1")
    for x=1, #specials do
        print("Hola2")
        if specials[x] == player.Name then
            print("Hola3")
            game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
                Text = "A special player has entered the game!"; 
                Color =  Color3.new(34/255,255/255,0/255);
                Font = Enum.Font.SourceSansBold; 
                FontSize = Enum.FontSize.Size18;
            })
        end
    end
end)
0
game:GetService("Players")? XAXA 1569 — 8y
0
what's the issue? BlueMond 30 — 8y
0
It doesn't print anything, TheHospitalDev 1134 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

That's quite an abstract way of checking a table but there's a lot simpler of a way using a for loop.

local specials = {"rexbit", "TheHospitalDev","etc"}

game.Players.PlayerAdded:connect(function(player)
    for x=1, #specials do
        if specials[x] == player.Name then
            --code to run
        end
    end
end)

Otherwise I'm not sure what you're asking.

0
Sorry. TheHospitalDev 1134 — 8y
0
Don't work :/ TheHospitalDev 1134 — 8y
Ad

Answer this question