Flaws with your script:
-You can't use plr:WaitForChild("Character") because the character is not a child of the player. We can use a while loop or the CharacterAdded() event, though a while loop is better to use further down in the code, since if we use CharacterAdded(), it might not pick up on the character spawning the first time depending on how long it takes the previous code to run.
-The test name for the player has two interchangeable names: "Player" and "Player1". Not sure
why, but you still have to compensate for it. We can fix this by putting both names in the table.
-You have the if statement inside of the for loop. That means that for each iteration through the table, if the mod is not a player, then it will print "A player has entered "..GameName.."!". We can fix this by using a variable that is true if the player is a mod, and use it to create an if statement that prints a mod has entered, otherwise a player has entered.
-Additionally, I'm assuming you want to clone the part into a moderator's character whenever he/she spawns instead of just once. For this, we can use the Character Added event.
I went ahead and made a script in super-safe mode, so you can use it with no risk.
Finished Script:
local Mods = {"LegendaryArmor","alphawolvess","Player","Player1","aquathorn321"}
local GameName = "FlobbyGames"
game.Players.PlayerAdded:connect(function(plr)
local b = false
local player = false
local m
m = plr.CharacterAdded:connect(function(character)
while not (b or player) do
wait()
end
if player then m:disconnect()
else
local Copy = game.ReplicatedStorage.Moderators:Clone()
Copy.Parent = character.Head
end
end)
for i,Mod in pairs(Mods) do
if plr.Name:lower() == Mod:lower() then
b = true
break
end
end
while not plr.Character do
wait()
end
if b then
print("A moderator has entered "..GameName.."!")
else
print("A player has entered "..GameName.."!")
player = true
end
end)
4 comments
Um, when I press play in studio, I see no where saying Player1? All I see is Player. I can take a photo and put on a website to show?
It's either Player1 or Player. Roblox switches names interchangeably; it's weird.
I said Mod because it would currently look at 1 mod, then the other... for the Table, it has more than 1. Just wondering, but is putting the exact name inside of a Table work as well? (Ik what :lower() does)
Oh, I did type Mod and Mods in the wrong spot. Sorry, sometimes my mind skips some things.