Script doesn't work and doesn't print error?

For some this script doesn’t work, it does not print anything nor gives me an error and I have no idea why that is. The script is located in serverscriptservice and is enabled, doesn’t work in-game either.

game.Players.PlayerAdded:Connect(function(player)
           local allowed = { "devilpyro33"}

for i, v in pairs(allowed) do
	if player.Name == v then
		print ("player is a moderator")
		wait (10)
		local clone = game.ServerStorage:FindFirstChild("modtext"):Clone()
		clone.Parent = game.Players:FindFirstChild(player.Name).PlayerGui
		print ("modtext clone sucessfull")
		wait (13)
		game.Players[player.Name].PlayerGui:FindFirstChild("modtext"):Destroy()
		print ("modtext deleted")
	else  return end

end

end)
2 Likes

Instead of using a for i,v in pairs loop, can’t you just use table.find() instead? It’d be way easier for this instance

local allowed = {"devilpyro33"}

game.Players.PlayerAdded:Connect(function(player)

    local AllowedPlayer = table.find(allowed, player.Name)
    if AllowedPlayer then --This returns either the Player name or nil
	    print ("player is a moderator")
		    wait(10)
		    local clone = game.ServerStorage:FindFirstChild("modtext"):Clone()
	   	    clone.Parent = player:WaitForChild("PlayerGui")
		    print ("modtext clone sucessfull")
            wait(13)
		    clone:Destroy()
		    print ("modtext deleted")
	    else 
            print ("player is not moderator")
        return 
    end
end)

It could just be possible that you have a random syntax error or something

Yeah thanks this worked, the “clone.Parent = player:WaitForChild(“PlayerGui”)” gave me an error but I just replaced it with “clone.Parent = game.Players[player.Name].PlayerGui”.