Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

PlayerAdded, ChatMessage help?

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)

3 comments

0

game:GetService("Players")?

0

what's the issue?

0

It doesn't print anything,

1 answer

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.

2 comments

0

Sorry.

0

Don't work :/

This discussion is preserved as it was. New answers, comments, and votes are closed.