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

PlayerAdded, ChatMessage help?

Asked by 9 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

01local specials = {"rexbit", "TheHospitalDev","Player","Player1"}
02 
03game.Players.PlayerAdded:connect(function(player)
04    print("Hola1")
05    for x=1, #specials do
06        print("Hola2")
07        if specials[x] == player.Name then
08            print("Hola3")
09            game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
10                Text = "A special player has entered the game!";
11                Color =  Color3.new(34/255,255/255,0/255);
12                Font = Enum.Font.SourceSansBold;
13                FontSize = Enum.FontSize.Size18;
14            })
15        end
16    end
17end)
0
game:GetService("Players")? XAXA 1569 — 9y
0
what's the issue? BlueMond 30 — 9y
0
It doesn't print anything, TheHospitalDev 1134 — 9y

1 answer

Log in to vote
1
Answered by 9 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.

1local specials = {"rexbit", "TheHospitalDev","etc"}
2 
3game.Players.PlayerAdded:connect(function(player)
4    for x=1, #specials do
5        if specials[x] == player.Name then
6            --code to run
7        end
8    end
9end)

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

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

Answer this question